BREAKING CHANGE:
Angular is now fully camel case.
Before:
    <p *ng-if="cond">
    <my-cmp [my-prop]="exp">
    <my-cmp (my-event)="action()">
    <my-cmp [(my-prop)]="prop">
    <input #my-input>
    <template ng-for #my-item [ng-for-of]=items #my-index="index">
After
    <p *ngIf="cond">
    <my-cmp [myProp]="exp">
    <my-cmp (myEvent)="action()">
    <my-cmp [(myProp)]="prop">
    <input #myInput>`,
    <template ngFor="#my-item" [ngForOf]=items #myIndex="index">
The full details are found in [angular2/docs/migration/kebab-case.md](https://github.com/angular/angular/blob/master/modules/angular2/docs/migration/kebab-case.md)
		
	
			
		
			
				
	
	
		
			74 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			74 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import {
 | 
						|
  AsyncTestCompleter,
 | 
						|
  TestComponentBuilder,
 | 
						|
  beforeEach,
 | 
						|
  ddescribe,
 | 
						|
  describe,
 | 
						|
  el,
 | 
						|
  expect,
 | 
						|
  iit,
 | 
						|
  inject,
 | 
						|
  it,
 | 
						|
  xit,
 | 
						|
} from 'angular2/testing_internal';
 | 
						|
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
 | 
						|
import {Component, Directive, View} from 'angular2/core';
 | 
						|
import {ElementRef} from 'angular2/src/core/linker/element_ref';
 | 
						|
 | 
						|
export function main() {
 | 
						|
  describe('non-bindable', () => {
 | 
						|
    it('should not interpolate children',
 | 
						|
       inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
 | 
						|
         var template = '<div>{{text}}<span ngNonBindable>{{text}}</span></div>';
 | 
						|
         tcb.overrideTemplate(TestComponent, template)
 | 
						|
             .createAsync(TestComponent)
 | 
						|
             .then((fixture) => {
 | 
						|
               fixture.detectChanges();
 | 
						|
               expect(fixture.debugElement.nativeElement).toHaveText('foo{{text}}');
 | 
						|
               async.done();
 | 
						|
             });
 | 
						|
       }));
 | 
						|
 | 
						|
    it('should ignore directives on child nodes',
 | 
						|
       inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
 | 
						|
         var template = '<div ngNonBindable><span id=child test-dec>{{text}}</span></div>';
 | 
						|
         tcb.overrideTemplate(TestComponent, template)
 | 
						|
             .createAsync(TestComponent)
 | 
						|
             .then((fixture) => {
 | 
						|
               fixture.detectChanges();
 | 
						|
 | 
						|
               // We must use DOM.querySelector instead of fixture.query here
 | 
						|
               // since the elements inside are not compiled.
 | 
						|
               var span = DOM.querySelector(fixture.debugElement.nativeElement, '#child');
 | 
						|
               expect(DOM.hasClass(span, 'compiled')).toBeFalsy();
 | 
						|
               async.done();
 | 
						|
             });
 | 
						|
       }));
 | 
						|
 | 
						|
    it('should trigger directives on the same node',
 | 
						|
       inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
 | 
						|
         var template = '<div><span id=child ngNonBindable test-dec>{{text}}</span></div>';
 | 
						|
         tcb.overrideTemplate(TestComponent, template)
 | 
						|
             .createAsync(TestComponent)
 | 
						|
             .then((fixture) => {
 | 
						|
               fixture.detectChanges();
 | 
						|
               var span = DOM.querySelector(fixture.debugElement.nativeElement, '#child');
 | 
						|
               expect(DOM.hasClass(span, 'compiled')).toBeTruthy();
 | 
						|
               async.done();
 | 
						|
             });
 | 
						|
       }));
 | 
						|
  })
 | 
						|
}
 | 
						|
 | 
						|
@Directive({selector: '[test-dec]'})
 | 
						|
class TestDirective {
 | 
						|
  constructor(el: ElementRef) { DOM.addClass(el.nativeElement, 'compiled'); }
 | 
						|
}
 | 
						|
 | 
						|
@Component({selector: 'test-cmp'})
 | 
						|
@View({directives: [TestDirective]})
 | 
						|
class TestComponent {
 | 
						|
  text: string;
 | 
						|
  constructor() { this.text = 'foo'; }
 | 
						|
}
 |