Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example usage of SegmentedBar? Having trouble with the component rendering improperly with bound items property #80

Closed
NathanWalker opened this issue Feb 22, 2016 · 5 comments

Comments

@NathanWalker
Copy link
Contributor

I'm having trouble getting a Segmented Bar to render properly when bound to a property in an angular component class.

<SegmentedBar items="{{supportedLanguages}}"></SegmentedBar>
...
export class LangSwitcherCmp {
  public supportedLanguages: Array<any> = [
    { code: 'en', title: 'English' },
    { code: 'es', title: 'Spanish' },
    { code: 'fr', title: 'French' },
    { code: 'ru', title: 'Russian' },
    { code: 'bg', title: 'Bulgarian' }
  ];
}

It ends up rendering like this... (am I missing something?):
screen shot 2016-02-21 at 5 02 26 pm

@NathanWalker
Copy link
Contributor Author

This is using the following dependencies btw:

"angular2": "2.0.0-beta.3",
"nativescript-angular": "0.0.31",
"parse5": "1.4.2",
"punycode": "1.3.2",
"querystring": "0.2.0",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"tns-core-modules": "1.6.0-angular-5",
"zone.js": "0.5.11"

Which is the latest of what is being used here:
https://github.com/NativeScript/qsf-angular-nativescript/blob/master/package.json#L33-L42

@NathanWalker NathanWalker changed the title Example usage of SegmentedBar ? Example usage of SegmentedBar? Having trouble with the component rendering improperly with bound items property Feb 22, 2016
@hdeshev
Copy link
Contributor

hdeshev commented Feb 22, 2016

I tried this binding:

<SegmentedBar [items]="supportedLanguages"></SegmentedBar>

and it worked just fine. I think the moustache binding is meant to be used only for HTML text nodes (it returns a string value, which won't work with the segmented bar). Since NativeScript has no text nodes, I'd advise against using those bindings.

@hdeshev hdeshev closed this as completed Feb 22, 2016
@NathanWalker
Copy link
Contributor Author

Ah yes of course thanks!!!

@burkeholland
Copy link

I'm having trouble getting the SegmentedBar to render with a static list of items in markup. If I have...

<SegmentedBar row="1" colspan="3" class="toggles" (selectedIndexChanged)="filter()" selectedBackgroundColor="#B76769">
  <SegmentedBar.items>
    <SegmentedBarItem title="All"></SegmentedBarItem>
    <SegmentedBarItem title="Active" completed="false"></SegmentedBarItem>
    <SegmentedBarItem title="Done" completed="true"></SegmentedBarItem>
  </SegmentedBar.items>
</SegmentedBar>

...shouldn't that display a SegmentedBar? Is there a way to do it differently in Angular 2?

@hdeshev
Copy link
Contributor

hdeshev commented Apr 12, 2016

This syntax (binding) will work for sure:

<SegmentedBar row="1" colspan="3" class="toggles"
  (selectedIndexChanged)="filter()" selectedBackgroundColor="#B76769"
  [items]="[{title: 'All'}, {title: 'Active'}]">
</SegmentedBar>

I opened a new issue related to supporting child <SegmentedBarItem> tags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants