angular2-template

Templating/rendering properties in an empty array in angular2?

我是研究僧i 提交于 2019-12-12 04:17:02
问题 http://jsfiddle.net/48yh14c3/ this.list = [ { property: [{anotherProp: true}] }, { property: [] }, { property: [{anotherProp: false}] } ] In angular 1 you could reference deep properties and (for the most part) it would keep on rocking: <div ng-repeat='thing in ctrl.list'> {{thing.property[0].anotherProp}} </div> I'm sure I could just *ngIf the parent property to make sure it exists, or flatten the original POJO. Just wondering if I'm missing something? 回答1: Yes, you're missing the Elvis

Event not working in dynamic html in angular2

放肆的年华 提交于 2019-12-12 03:58:21
问题 Want to append the dynamic generated html in a DOM, its appending successfully in a DOM but none of the function is working like click etc. ngOnInit() { this.sideBarData += '<li class="sidebar-toggler-wrapper hide" >' + '<div class="sidebar-toggler" > </div>' + '</li>' + '<li class="sidebar-search-wrapper"></li>'; this.sideBarData += '<li class="nav-item start">' + '<a class="nav-link home name" (click)="HomeButton(event)">' + '<i class="fa fa-home"></i>' + '<span class="title">Home</span>' +

@Input binding doesn't work when I put it under a router component

孤人 提交于 2019-12-12 03:35:15
问题 Updated Answer I've just found out what happened. I have to load the script pollyfills after systemjs . Well, this is an known issue of the router: Concat/Load Order 'node_modules/systemjs/dist/system.src.js', 'node_modules/angular2/bundles/angular2-polyfills.js' Problem I am trying to use my own component library in my app. After I put the component under a page inside a router component, the component's title decorated with @Input doesn't show up: I need it renders the title properties

Angular 2 items don't update when changed from phonegap notification dialog

*爱你&永不变心* 提交于 2019-12-12 02:51:56
问题 I am building an phonegap app with angular2. I want to show a confirmation dialog and in success callback to update elements from angular2 view. When I do this nothing happens right away, but if I update other model on the page (what is linked with angular) my update is updated. For confirmation dialog I use phonegap plugin: cordova-plugin-dialogs and the method called is: navigator.notification.confirm(...) . Here is my full code of my Component: AboutComponent = ng.core .Component({

Angular2 pass dynamic content to a component

≯℡__Kan透↙ 提交于 2019-12-12 02:14:17
问题 I have a ListComponent that basically loops on an array of objects with ngFor + some functionality. I would like to be able to pass different 'item' components as content of the ListComponent like this: <list-component> <item-component [SomeInput]="someInput"> <some-content></some-content> </item-component> </list-component> and in another place: <list-component> <different-item-component [SomeInput]="someInput"> <some-content></some-content> </different-item-component> </list-component> and

Can TestComponentBuilder test an angular component within a component?

本小妞迷上赌 提交于 2019-12-11 23:33:19
问题 So, I'm trying to write a unit test for my component. My component is a dynamically created list, and when a user clicks certain items, I'd like my test to validate that the component generates outputs correctly. To test this, I wrote a demo component that creates my component within its template, and then attempted to get TestComponentBuilder to create this demo component and click items on the lists. Unfortunately, my unit test cases can't find my component's html elements to click them. I

Accessing array in component from ionic view

依然范特西╮ 提交于 2019-12-11 17:04:52
问题 this.tribesProvider.getMyTribeDetailsByTriberId().subscribe(tribeIds=>{ tribeIds.forEach(tribeId=>{ this.tribesProvider.getMyTribeDetailsByTribeId(tribeId).subscribe(tribe=>{ this.myTribeList.push(tribe); console.log(this.myTribeList); }) }) }) I have to access the array myTribeList from its view like this <ion-item *ngFor="let tribe of myTribeList"> <ion-list> <h2>{{tribe.TribeDesc}}</h2> <h2>{{tribe.TribeName}}</h2> <h2>{{tribe.Created}}</h2> <h2>{{tribe.Updated}}</h2> </ion-list> </ion

how to get value outside subscribe in angular2

久未见 提交于 2019-12-11 16:22:48
问题 Well, I have created a function inside the component.ts file which is placed inside the constructor: constructor(private _visitService: VisitService,) { this._visitService.getchartData().subscribe(data => { this.fetchedData = data console.log("INSIDE SUBSCRIBE", this.fetchedData ); }); } It is fine when the data is to be used within the subscribe curly brackets {} like the console.log did. but when i put it in a function outside like this: constructor( private _visitService: VisitService, ) {

Angular2: Update all color assignments in CSS dynamically

我怕爱的太早我们不能终老 提交于 2019-12-11 14:29:48
问题 I have an angular 2 application in which I'd like to implement the ability for a user to choose their color theme from a list of predetermined color palettes. When they select a theme, ALL relevant instances of color, background-color, etc will be changed to the corresponding new color from the theme palette. Is there any way to implement this from an Angular controller? I know that you can conditionally add classes to specific elements using [class.className] or [ngClass] but obviously it is

Use content of component template in angular 2 [duplicate]

梦想与她 提交于 2019-12-11 11:49:59
问题 This question already has answers here : Custom template(transclusion without ng-content) for list component in Angular2 (3 answers) Closed 3 years ago . RE DUPLICATE: "This question has been asked before and already has an answer. " So this question was asked 10 days after I asked it? Somebody doesn't know how to read time stamps. I'm struggling with Angular 2 making it hard or perhaps impossible to do things that were trivial in Angular 1, especially without tons of superfluous code and/or