我知道它与任何编码无关,但它们可以遵循与 Angular 1 中相同的语法
<input ng-model="hero.name" placeholder="name" type="text">
到目前为止,AngulAR 2 及其更高版本的语法
<input [(ngModel)]="hero.name" placeholder="name" type="text">
如果他们这样做,对人们适应 Angular JS 的变化会有很大帮助吗?
与ng-repeat
类似,他们改为ngFor
<ul ngFor let-item [ngForOf]="items" let-i="index" [ngForTrackBy]="trackByFn">
<li>...</li>
</ul>
<ul ng-repeat="item in items track by myTrackingFunction(n)">
<li>...</li>
</ul>
最佳答案
香蕉括号用于双向绑定(bind)。
见
Binding syntax:
Data binding is a mechanism for coordinating what users see, with application data values. While you could push values to and pull values from HTML, the application is easier to write, read, and maintain if you turn these chores over to a binding framework. You simply declare bindings between binding sources and target HTML elements and let the framework do the work.
Angular provides many kinds of data binding. This guide covers most of them, after a high-level view of Angular data binding and its syntax.
Binding types can be grouped into three categories distinguished by the direction of data flow: from the source-to-view, from view-to-source, and in the two-way sequence: view-to-source-to-view.
关于javascript - 为什么 Angular 2 或 Angular 4 使用香蕉括号?有什么具体原因吗?为什么他们不遵循与 Angular 1 相同的模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43607916/