refactor(directives): Drop ng- prefix from all angular directives and rename NgRepeat to Foreach
fixes #532 Closes #539
This commit is contained in:
@ -6,7 +6,7 @@ import {bootstrap, Component, Template, TemplateConfig, ViewPort, Compiler}
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {ScrollAreaComponent} from './scroll_area';
|
||||
import {NgIf, NgRepeat} from 'angular2/directives';
|
||||
import {If, Foreach} from 'angular2/directives';
|
||||
import {DOM, document, Element} from 'angular2/src/facade/dom';
|
||||
|
||||
export class App {
|
||||
@ -86,7 +86,7 @@ export function setupReflectorForApp() {
|
||||
new Component({
|
||||
selector: 'scroll-app',
|
||||
template: new TemplateConfig({
|
||||
directives: [ScrollAreaComponent, NgIf, NgRepeat],
|
||||
directives: [ScrollAreaComponent, If, Foreach],
|
||||
inline: `
|
||||
<div>
|
||||
<div style="display: flex">
|
||||
@ -96,9 +96,9 @@ export function setupReflectorForApp() {
|
||||
<button id="reset-btn">Reset</button>
|
||||
</div>
|
||||
</div>
|
||||
<div template="ng-if scrollAreas.length > 0">
|
||||
<div template="if scrollAreas.length > 0">
|
||||
<p>Following tables are only here to add weight to the UI:</p>
|
||||
<scroll-area template="ng-repeat #scrollArea in scrollAreas"></scroll-area>
|
||||
<scroll-area template="foreach #scrollArea in scrollAreas"></scroll-area>
|
||||
</div>
|
||||
</div>`
|
||||
})
|
||||
|
@ -7,7 +7,7 @@ import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
|
||||
import {Company, Opportunity, Offering, Account, CustomDate, STATUS_LIST}
|
||||
from './common';
|
||||
import {NgRepeat} from 'angular2/directives';
|
||||
import {Foreach} from 'angular2/directives';
|
||||
|
||||
export class HasStyle {
|
||||
style:Map;
|
||||
@ -158,10 +158,10 @@ export function setupReflectorForCells() {
|
||||
new Component({
|
||||
selector: 'stage-buttons',
|
||||
template: new TemplateConfig({
|
||||
directives: [NgRepeat],
|
||||
directives: [Foreach],
|
||||
inline: `
|
||||
<div [style]="style">
|
||||
<button template="ng-repeat #stage in stages"
|
||||
<button template="foreach #stage in stages"
|
||||
[disabled]="stage.isDisabled"
|
||||
[style]="stage.style"
|
||||
on-click="setStage(stage)">
|
||||
|
@ -15,7 +15,7 @@ import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle';
|
||||
import {XHR} from 'angular2/src/core/compiler/xhr/xhr';
|
||||
import {XHRImpl} from 'angular2/src/core/compiler/xhr/xhr_impl';
|
||||
|
||||
import {NgIf, NgRepeat} from 'angular2/directives';
|
||||
import {If, Foreach} from 'angular2/directives';
|
||||
import {App, setupReflectorForApp} from './app';
|
||||
import {ScrollAreaComponent, setupReflectorForScrollArea} from './scroll_area';
|
||||
import {ScrollItemComponent, setupReflectorForScrollItem} from './scroll_item';
|
||||
@ -149,22 +149,22 @@ export function setupReflector() {
|
||||
}
|
||||
|
||||
export function setupReflectorForAngular() {
|
||||
reflector.registerType(NgIf, {
|
||||
'factory': (vp) => new NgIf(vp),
|
||||
reflector.registerType(If, {
|
||||
'factory': (vp) => new If(vp),
|
||||
'parameters': [[ViewPort]],
|
||||
'annotations' : [new Template({
|
||||
selector: '[ng-if]',
|
||||
selector: '[if]',
|
||||
bind: {
|
||||
'ng-if': 'condition'
|
||||
'if': 'condition'
|
||||
}
|
||||
})]
|
||||
});
|
||||
|
||||
reflector.registerType(NgRepeat, {
|
||||
'factory': (vp) => new NgRepeat(vp),
|
||||
reflector.registerType(Foreach, {
|
||||
'factory': (vp) => new Foreach(vp),
|
||||
'parameters': [[ViewPort]],
|
||||
'annotations' : [new Template({
|
||||
selector: '[ng-repeat]',
|
||||
selector: '[foreach]',
|
||||
bind: {
|
||||
'in': 'iterable[]'
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import {Offering, ITEMS, ITEM_HEIGHT, VISIBLE_ITEMS, VIEW_PORT_HEIGHT,
|
||||
ROW_WIDTH, HEIGHT} from './common';
|
||||
import {generateOfferings} from './random_data';
|
||||
import {ScrollItemComponent} from './scroll_item';
|
||||
import {NgRepeat} from 'angular2/directives';
|
||||
import {Foreach} from 'angular2/directives';
|
||||
|
||||
export class ScrollAreaComponent {
|
||||
_fullList:List<Offering>;
|
||||
@ -68,7 +68,7 @@ export function setupReflectorForScrollArea() {
|
||||
new Component({
|
||||
selector: 'scroll-area',
|
||||
template: new TemplateConfig({
|
||||
directives: [ScrollItemComponent, NgRepeat],
|
||||
directives: [ScrollItemComponent, Foreach],
|
||||
inline: `
|
||||
<div>
|
||||
<div id="scrollDiv"
|
||||
@ -77,7 +77,7 @@ export function setupReflectorForScrollArea() {
|
||||
<div id="padding"></div>
|
||||
<div id="inner">
|
||||
<scroll-item
|
||||
template="ng-repeat #item in visibleItems"
|
||||
template="foreach #item in visibleItems"
|
||||
[offering]="item">
|
||||
</scroll-item>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user