ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

buttons inside component not rendered correctly

Open lbickston opened this issue 10 years ago • 5 comments

Short description of the problem:

Buttons are not rendering correctly within a component. See the screenshot below for three buttons rendered correctly inside a normal element. Right below it are three buttons rendered inside a component. They do not render correctly.

screen shot 2016-03-16 at 11 25 10 pm

button-component.js

import {Component} from 'angular2/core'
@Component({
  selector: 'button-component',
  templateUrl: 'build/components/button-component/button-component.html',
})
export class ButtonComponent {
  constructor() {
  }
}

button-component.html

<button>Primary</button>
<button full>Full Button</button>
<button>
  <ion-icon name="home"></ion-icon>
</button>

Here is the rendered html from the screenshot example

<button _ngcontent-nat-14="" class="disable-hover button button-default"><span class="button-inner">Primary</span><ion-button-effect></ion-button-effect></button>
<button _ngcontent-nat-14="" full="" class="disable-hover button button-default button-full"><span class="button-inner">Full Button</span><ion-button-effect></ion-button-effect></button>
<button _ngcontent-nat-14="" class="disable-hover button button-default button-icon-only"><span class="button-inner">
  <ion-icon _ngcontent-nat-14="" name="home" role="img" class="ion-ios-home" aria-label="home"></ion-icon>
</span><ion-button-effect></ion-button-effect></button>
<br _ngcontent-nat-14="">
<br _ngcontent-nat-14="">

<button-component _ngcontent-nat-14="">
<button>Primary</button>
<button full="">Full Button</button>
<button>
  <ion-icon name="home"></ion-icon>
</button>
</button-component>

Which Ionic Version? 2.x

Run ionic info from terminal/cmd prompt:

Cordova CLI: 6.0.0 Gulp version: CLI version 3.9.1 Gulp local: Local version 3.9.1 Ionic Version: 2.0.0-beta.3 Ionic CLI Version: 2.0.0-beta.19 Ionic App Lib Version: 2.0.0-beta.9 ios-deploy version: 1.8.5 ios-sim version: 5.0.6 OS: Mac OS X El Capitan Node Version: v5.5.0 Xcode version: Xcode 7.2.1 Build version 7C1002

lbickston avatar Mar 17 '16 03:03 lbickston

Thanks for opening this issue with us! Are you getting any errors in your console?

jgw96 avatar Mar 17 '16 14:03 jgw96

@jgw96 Nope. No errors in the console.

lbickston avatar Mar 17 '16 14:03 lbickston

Ahh, sorry i should have seen this earlier. For all custom components you will need to import in IONIC_DIRECTIVES and add it to your directives: [] array. This should then solve your issue. If you would like to read up more custom components in Ionic 2, or if i just didn't explain it well heres the link: http://ionicframework.com/docs/v2/api/decorators/Page/. Let me know if this doesn't fix your issue and ill reopen!

jgw96 avatar Mar 17 '16 15:03 jgw96

@jgw96. thanks. works perfectly.

lbickston avatar Mar 17 '16 15:03 lbickston

@djangojack no problem! Glad i could help!

jgw96 avatar Mar 17 '16 15:03 jgw96