Tag: angular2 directives

为angular2实现自动完成

我无法为Angular2find一个很好的自动完成组件。 只要我可以传递一个键列表,标签对象,并在input字段上有一个很好的自动完成。 Kendo目前还不支持angular2,而且我们主要在内部使用它。 看起来angular材料不支持angular2。 任何人都可以请指出我在正确的方向或让我知道他们正在使用? 这是我迄今为止build立的。 这是非常糟糕的,我想find一些看起来不错的东西。 import {Component, EventEmitter, Input, Output} from 'angular2/core'; import {Control} from 'angular2/common'; import {Observable} from 'rxjs/Observable'; import {SimpleKeyValue} from '../models/simple-key-value' import 'rxjs/add/operator/map'; import 'rxjs/add/operator/debounceTime'; import 'rxjs/add/operator/distinctUntilChanged'; @Component({ selector: 'general-typeahead', template: ` <div> <div class="input-group"> <input type="text" [ngFormControl] = "term" class="form-control" placeholder={{placeHolder}} > </div> <ul> <li class="item" *ngFor="#item of matchingItems" […]

Angular 2滚动到路由更改上方

在我的Angular 2应用程序中,当我向下滚动页面并单击页面底部的链接时,它确实会更改路线,并将我带到下一页,但不会滚动到页面的顶部。 因此,如果第一页冗长而第二页内容less,则给人一种第二页缺less内容的印象。 由于内容只有在用户滚动到页面顶部时才可见。 我可以将窗口滚动到组件的ngInit页面的顶部,但是,有没有更好的解决scheme,可以自动处理我的应用程序中的所有路线?

我怎样才能在angular 2中使用angular.copy

我怎样才能复制一个对象,并在angular度2中失去它的参考? 与angular1我使用angular.copy(object) ,但我得到一些错误使用angular2。 EXCEPTION:ReferenceError:未定义angular度

如何扩展/inheritanceAngular2组件?

题 我想为已经部署在Angular 2中的一些组件创build扩展,而不必几乎完全重写它们,因为基本组件可能发生变化,并希望这些变化也反映在派生的组件中。 例 我创build了这个简单的例子,试图解释更好的问题: 使用以下基本组件app/base-panel.component.ts : import {Component, Input} from 'angular2/core'; @Component({ selector: 'base-panel', template: '<div class="panel" [style.background-color]="color" (click)="onClick($event)">{{content}}</div>', styles: [` .panel{ padding: 50px; } `] }) export class BasePanelComponent { @Input() content: string; color: string = "red"; onClick(event){ console.log("Click color: " + this.color); } } 您是否想创build另一个派生组件,例如,在示例颜色app/my-panel.component.ts的情况下,基本组件行为: import {Component} from 'angular2/core'; import {BasePanelComponent} from […]

Angular2exception:由于它不是已知的本地属性,因此无法绑定到“ngForIn”

我究竟做错了什么? import {bootstrap, Component} from 'angular2/angular2' @Component({ selector: 'conf-talks', template: `<div *ngFor="let talk in talks"> {{talk.title}} by {{talk.speaker}} <p>{{talk.description}} </div>` }) class ConfTalks { talks = [ {title: 't1', speaker: 'Brian', description: 'talk 1'}, {title: 't2', speaker: 'Julie', description: 'talk 2'}]; } @Component({ selector: 'my-app', directives: [ConfTalks], template: '<conf-talks></conf-talks>' }) class App {} bootstrap(App, []) […]

NgFor不会使用Angular2中的Pipe更新数据

在这种情况下,我使用ngFor显示了学生(数组)的视图列表: <li *ngFor="#student of students">{{student.name}}</li> 当我将其他学生添加到列表中时,它会更新。 但是,当我给它一个pipe道过滤学生的名字, <li *ngFor="#student of students | sortByName:queryElem.value ">{{student.name}}</li> 它不会更新列表,直到我在筛选学生名称字段中键入内容。 这是一个plnkr的链接。 Hello_world.html <h1>Students:</h1> <label for="newStudentName"></label> <input type="text" name="newStudentName" placeholder="newStudentName" #newStudentElem> <button (click)="addNewStudent(newStudentElem.value)">Add New Student</button> <br> <input type="text" placeholder="Search" #queryElem (keyup)="0"> <ul> <li *ngFor="#student of students | sortByName:queryElem.value ">{{student.name}}</li> </ul> sort_by_name_pipe.ts import {Pipe} from 'angular2/core'; @Pipe({ name: 'sortByName' }) export class […]