chore: rename for to ng-for
Closes #1598 Closes #1295 Closes #1827 Closes #1827
This commit is contained in:
@@ -533,7 +533,7 @@ export function main() {
|
||||
|
||||
it('should allow multiple pairs', () => {
|
||||
var bindings = parseTemplateBindings("a 1 b 2");
|
||||
expect(keys(bindings)).toEqual(['a', 'b']);
|
||||
expect(keys(bindings)).toEqual(['a', 'a-b']);
|
||||
expect(exprSources(bindings)).toEqual(['1 ', '2']);
|
||||
});
|
||||
|
||||
@@ -565,7 +565,7 @@ export function main() {
|
||||
expect(keyValues(bindings)).toEqual(['keyword', '#item=\$implicit', '#i=k']);
|
||||
|
||||
bindings = parseTemplateBindings("directive: var item in expr; var a = b", 'location');
|
||||
expect(keyValues(bindings)).toEqual(['directive', '#item=\$implicit', 'in=expr in location', '#a=b']);
|
||||
expect(keyValues(bindings)).toEqual(['directive', '#item=\$implicit', 'directive-in=expr in location', '#a=b']);
|
||||
});
|
||||
|
||||
it('should parse pipes', () => {
|
||||
|
||||
+3
-3
@@ -33,7 +33,7 @@ import {Parent, Ancestor} from 'angular2/src/core/annotations_impl/visibility';
|
||||
import {Attribute, Query} from 'angular2/src/core/annotations_impl/di';
|
||||
|
||||
import {NgIf} from 'angular2/src/directives/ng_if';
|
||||
import {For} from 'angular2/src/directives/for';
|
||||
import {NgFor} from '../../../src/directives/ng_for';
|
||||
|
||||
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
|
||||
import {ProtoViewRef} from 'angular2/src/core/compiler/view_ref';
|
||||
@@ -1517,8 +1517,8 @@ class ToolbarPart {
|
||||
selector: 'toolbar'
|
||||
})
|
||||
@View({
|
||||
template: 'TOOLBAR(<div *for="var part of query" [toolbar-vc]="part"></div>)',
|
||||
directives: [ToolbarViewContainer, For]
|
||||
template: 'TOOLBAR(<div *ng-for="var part of query" [toolbar-vc]="part"></div>)',
|
||||
directives: [ToolbarViewContainer, NgFor]
|
||||
})
|
||||
class ToolbarComponent {
|
||||
query:QueryList;
|
||||
|
||||
@@ -17,7 +17,7 @@ import {TestBed} from 'angular2/src/test_lib/test_bed';
|
||||
import {QueryList} from 'angular2/src/core/compiler/query_list';
|
||||
import {Query} from 'angular2/src/core/annotations_impl/di';
|
||||
|
||||
import {NgIf, For} from 'angular2/angular2';
|
||||
import {NgIf, NgFor} from 'angular2/angular2';
|
||||
|
||||
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
|
||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||
@@ -66,7 +66,7 @@ export function main() {
|
||||
it('should reflect moved directives', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
var template =
|
||||
'<div text="1"></div>' +
|
||||
'<needs-query text="2"><div *for="var i of list" [text]="i"></div></needs-query>' +
|
||||
'<needs-query text="2"><div *ng-for="var i of list" [text]="i"></div></needs-query>' +
|
||||
'<div text="4"></div>';
|
||||
|
||||
tb.createView(MyComp, {html: template}).then((view) => {
|
||||
@@ -88,8 +88,8 @@ export function main() {
|
||||
|
||||
@Component({selector: 'needs-query'})
|
||||
@View({
|
||||
directives: [For],
|
||||
template: '<div *for="var dir of query">{{dir.text}}|</div>'
|
||||
directives: [NgFor],
|
||||
template: '<div *ng-for="var dir of query">{{dir.text}}|</div>'
|
||||
})
|
||||
class NeedsQuery {
|
||||
query: QueryList;
|
||||
@@ -113,7 +113,7 @@ class TextDirective {
|
||||
|
||||
@Component({selector: 'my-comp'})
|
||||
@View({
|
||||
directives: [NeedsQuery, TextDirective, NgIf, For]
|
||||
directives: [NeedsQuery, TextDirective, NgIf, NgFor]
|
||||
})
|
||||
class MyComp {
|
||||
shouldShow: boolean;
|
||||
|
||||
Vendored
+11
-11
@@ -18,14 +18,14 @@ import {ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {Component} from 'angular2/src/core/annotations_impl/annotations';
|
||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||
|
||||
import {For} from 'angular2/src/directives/for';
|
||||
import {NgFor} from '../../src/directives/ng_for';
|
||||
|
||||
import {TestBed} from 'angular2/src/test_lib/test_bed';
|
||||
|
||||
|
||||
export function main() {
|
||||
describe('for', () => {
|
||||
var TEMPLATE = '<div><copy-me template="for #item of items">{{item.toString()}};</copy-me></div>';
|
||||
describe('ng-for', () => {
|
||||
var TEMPLATE = '<div><copy-me template="ng-for #item of items">{{item.toString()}};</copy-me></div>';
|
||||
|
||||
it('should reflect initial elements', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
tb.createView(TestComponent, {html: TEMPLATE}).then((view) => {
|
||||
@@ -87,7 +87,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should iterate over an array of objects', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
var template = '<ul><li template="for #item of items">{{item["name"]}};</li></ul>';
|
||||
var template = '<ul><li template="ng-for #item of items">{{item["name"]}};</li></ul>';
|
||||
|
||||
tb.createView(TestComponent, {html: template}).then((view) => {
|
||||
|
||||
@@ -113,7 +113,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should gracefully handle nulls', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
var template = '<ul><li template="for #item of null">{{item}};</li></ul>';
|
||||
var template = '<ul><li template="ng-for #item of null">{{item}};</li></ul>';
|
||||
tb.createView(TestComponent, {html: template}).then((view) => {
|
||||
view.detectChanges();
|
||||
expect(DOM.getText(view.rootNodes[0])).toEqual('');
|
||||
@@ -162,8 +162,8 @@ export function main() {
|
||||
it('should repeat over nested arrays', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
var template =
|
||||
'<div>'+
|
||||
'<div template="for #item of items">' +
|
||||
'<div template="for #subitem of item">' +
|
||||
'<div template="ng-for #item of items">' +
|
||||
'<div template="ng-for #subitem of item">' +
|
||||
'{{subitem}}-{{item.length}};' +
|
||||
'</div>|'+
|
||||
'</div>'+
|
||||
@@ -187,8 +187,8 @@ export function main() {
|
||||
it('should repeat over nested arrays with no intermediate element',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
var template =
|
||||
'<div><template [for] #item [of]="items">' +
|
||||
'<div template="for #subitem of item">' +
|
||||
'<div><template [ng-for] #item [ng-for-of]="items">' +
|
||||
'<div template="ng-for #subitem of item">' +
|
||||
'{{subitem}}-{{item.length}};' +
|
||||
'</div></template></div>';
|
||||
|
||||
@@ -207,7 +207,7 @@ export function main() {
|
||||
it('should display indices correctly',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
var template =
|
||||
'<div><copy-me template="for: var item of items; var i=index">{{i.toString()}}</copy-me></div>';
|
||||
'<div><copy-me template="ng-for: var item of items; var i=index">{{i.toString()}}</copy-me></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: template}).then((view) => {
|
||||
view.context.items = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
@@ -231,7 +231,7 @@ class Foo {
|
||||
}
|
||||
|
||||
@Component({selector: 'test-cmp'})
|
||||
@View({directives: [For]})
|
||||
@View({directives: [NgFor]})
|
||||
class TestComponent {
|
||||
items: any;
|
||||
constructor() {
|
||||
Reference in New Issue
Block a user