angular2-template

Template with *ngIf inner, not work after change model

你离开我真会死。 提交于 2019-12-12 11:25:28
问题 Problem After the version of Angular 2.2. *, I noticed a problem in some components of my application, that after updating the data, the data was wrong in the view (it presented the list with the right size, but only with the data only of the first item) . Demonstration I created this Plunker with a simple example of the problem. This type of use causes the problem: <list-component [data]="list"> <template pTemplate let-item> <b *ngIf="item % 2 == 0">{{item}}</b> <del *ngIf="item % 2 != 0">{

How to use angular2-data-table

馋奶兔 提交于 2019-12-12 10:51:55
问题 Can't find any tutorial of how to use angular2-data-table library is here: https://github.com/swimlane/angular2-data-table The documentation seems to be lacking simple examples. Can any one give me a simple example of using datatable in angular2 回答1: I don't recomend using that library for that exact reason. I've been working for a couple of weeks trying to use it in a project and the lack of documentation has made it almost impossible to use. With that being said here is a relativly simple

Angular2 nested ngFor

这一生的挚爱 提交于 2019-12-12 09:28:43
问题 I need to do an equivalent of this in Angular2 : <?php foreach ($somethings as $something) { foreach ($something->children as $child) { echo '<tr>...</tr>'; } } Can this be achieved with ngFor and not adding new elements between <table> and <tr> ? 回答1: I have a sample that might be similar to what you want: <table id="spreadsheet"> <tr *ngFor="let row of visibleRows"> <td class="row-number-column">{{row.rowIndex}}</td> <td *ngFor="let col of row.columns"> <input data-id="{{col.rowIndex}}-{

Angular, how parse template from string and pass current context variables

余生颓废 提交于 2019-12-12 08:59:27
问题 I making a simple component to create tables: @Component({ selector: 'admin-table', template: ` <table class='table table-bordered'> <thead> <th *ngFor='let column of columns'> {{ column.label }} </th> </thead> <tbody> <tr *ngFor="let record of records"> <td *ngFor='let column of columns' [innerHTML]="fieldContent(column, record) | safeHtml"> </td> </tr> </tbody> </table> `, }) export class AdminTableComponent { @Input() columns: AdminTableColumn[]; @Input() records: {}[]; fieldContent(column

cordova app angular 2 member variable update not updating template reference to it

谁说我不能喝 提交于 2019-12-12 06:36:57
问题 i have a simple cordova app angular 2 test where @Component decorated AppComponent class member variable is updated when button click method starts and later when i land in callback for promise enabled method it calls. that member variable is referenced in the @component template as per the getting started tutorials. what i'm finding is that when i debug/test this in ripple emulator [ / chrome ] the first member variable update gets rendered in view template but the 2nd one doesn't.

Angular 4 Changes based on view

情到浓时终转凉″ 提交于 2019-12-12 06:02:22
问题 I have a div which is like <div [ngClass]="{'active' : isActive} [ngStyle]={top: topVar } > isActive and topVar are calculated based on the view, (like if the content overflowed, and the content is dynamic). so I calculate them in ngAfterViewChecked. which ofcourse gives me this error : Expression has changed after it was checked, previous value : "undefined". current value : '636px'. I understand what I did wrong, my question is, how to do it right? (If I calculate the the vars based on the

Angular2 Auto suggester

夙愿已清 提交于 2019-12-12 05:58:56
问题 I have been searching a lot on INTERNET but still unable to figure out how i can make custom auto suggester without any third party. After a lot of google I found this but the issue is that my response from api is a bit different i am getting response as : [{"id":"1","name":"aa"},{"id":"2","name":"bb"}...] due to which i am getting [object][object] as value in pipe. Can anyone please help how i can handle this request with this pipe. I want that their should be a text box on whose click there

How to use a child template inside a custom table component to display each row?

走远了吗. 提交于 2019-12-12 05:27:08
问题 I've tried so many things and failed that my code ended up being a total mess. I'm open to anything but, in case you want a base: The most promising approach I found was the following, but failed with the exception "templateRef.createEmbeddedView is not a function": app.component.html <br> <mt-table [fields]="userFields" [(rows)]="users" [pageSize]="10" [searchString]="searchString" class="round"> <template let-row="row"> <td> {{ row.name }} </td> <td> <i class="fa fa-{{ row.gender === 'male'

routerLink not compiling with TS template syntax

半城伤御伤魂 提交于 2019-12-12 05:17:37
问题 I have a component like this http://plnkr.co/edit/mJDHZIm5IzeMB9f2IVLE: @Component({ template: ` <p [innerHTML]="link"></p> `, directives: [ROUTER_DIRECTIVES] }) @RouteConfig([ { path: '/two', component: Two, name: 'Two'}, ]) export class App { two = (text: string) => `<a [routerLink]="['/Two']">${text}</a>`; constructor(private _router: Router) { } ngOnInit() { this.link = `${this.two("two")}`; } } Any ideas why it's not compiling link value or how to make it work? The goal is to hardcode

ViewChild - Angular 2 Javascript

孤人 提交于 2019-12-12 04:59:26
问题 How can I use ViewChild in Angular 2 Javascript? I have referred angular.io docs and I have tried with the following code and it is not working. Can anyone help me? Thanks in advance. main.html <router-outlet></router-outlet> app.component.js (function (app) { app.AppComponent = ng.core .Component({ selector: 'my-app', templateUrl: 'app/views/main.html', directives: [ng.router.ROUTER_DIRECTIVES], //<----not loading components here viewProviders: [ng.http.HTTP_PROVIDERS], queries: {