+9
-1
@@ -636,7 +636,15 @@ gulp.task('_zip-examples', function() {
|
||||
// Linting
|
||||
|
||||
gulp.task('lint', function() {
|
||||
return gulp.src(['./public/docs/_examples/style-guide/ts/**/*.ts', '!./public/docs/_examples/style-guide/ts/**/*.avoid.ts'])
|
||||
return gulp.src([
|
||||
'./public/docs/_examples/**/*.ts',
|
||||
'!./public/docs/_examples/**/ts-snippets/*.ts',
|
||||
'!./public/docs/_examples/style-guide/ts/**/*.avoid.ts',
|
||||
'!./public/docs/_examples/**/node_modules/**/*',
|
||||
'!./public/docs/_examples/_protractor/**/*',
|
||||
'!./public/docs/_examples/**/typings/**/*',
|
||||
'!./public/docs/_examples/**/typings-ng1/**/*'
|
||||
])
|
||||
.pipe(tslint({
|
||||
rulesDirectory: ['node_modules/codelyzer'],
|
||||
configuration: require('./tslint.json')
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
"browser-sync": "^2.9.3",
|
||||
"canonical-path": "0.0.2",
|
||||
"cross-spawn": "^4.0.0",
|
||||
"codelyzer": "0.0.20",
|
||||
"codelyzer": "0.0.22",
|
||||
"del": "^2.2.0",
|
||||
"dgeni": "^0.4.0",
|
||||
"dgeni-packages": "^0.13.0",
|
||||
|
||||
@@ -13,7 +13,7 @@ const HEROES = [
|
||||
export class BackendService {
|
||||
constructor(private logger: Logger) {}
|
||||
|
||||
getAll(type:Type) : PromiseLike<any[]>{
|
||||
getAll(type: Type): PromiseLike<any[]> {
|
||||
if (type === Hero) {
|
||||
// TODO get from the database
|
||||
return Promise.resolve<Hero[]>(HEROES);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, Input} from '@angular/core';
|
||||
import { Component, Input } from '@angular/core';
|
||||
|
||||
import { Hero } from './hero';
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ export class SalesTaxComponent {
|
||||
constructor(private salesTaxService: SalesTaxService) { }
|
||||
// #enddocregion ctor
|
||||
|
||||
getTax(value:string | number){
|
||||
getTax(value: string | number) {
|
||||
return this.salesTaxService.getVAT(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// #docregion
|
||||
import { Inject, Injectable } from '@angular/core';
|
||||
import { Inject, Injectable } from '@angular/core';
|
||||
|
||||
import { TaxRateService } from './tax-rate.service';
|
||||
|
||||
@@ -7,9 +7,9 @@ import { TaxRateService } from './tax-rate.service';
|
||||
@Injectable()
|
||||
export class SalesTaxService {
|
||||
constructor(private rateService: TaxRateService) { }
|
||||
getVAT(value:string | number){
|
||||
let amount:number;
|
||||
if (typeof value === "string"){
|
||||
getVAT(value: string | number) {
|
||||
let amount: number;
|
||||
if (typeof value === 'string') {
|
||||
amount = parseFloat(value);
|
||||
} else {
|
||||
amount = value;
|
||||
|
||||
@@ -4,6 +4,6 @@ import { Injectable } from '@angular/core';
|
||||
// #docregion class
|
||||
@Injectable()
|
||||
export class TaxRateService {
|
||||
getRate(rateName:string){return 0.10;} // always 10% everywhere
|
||||
getRate(rateName: string) {return 0.10; } // always 10% everywhere
|
||||
}
|
||||
// #enddocregion class
|
||||
|
||||
@@ -11,4 +11,4 @@ import { HighlightDirective } from './highlight.directive';
|
||||
|
||||
export class AppComponent { }
|
||||
|
||||
// #enddocregion
|
||||
// #enddocregion
|
||||
|
||||
@@ -14,12 +14,12 @@ import { Directive, ElementRef, Input } from '@angular/core';
|
||||
export class HighlightDirective {
|
||||
|
||||
// #docregion ctor
|
||||
private el:HTMLElement;
|
||||
private el: HTMLElement;
|
||||
constructor(el: ElementRef) { this.el = el.nativeElement; }
|
||||
// #enddocregion ctor
|
||||
|
||||
// #docregion mouse-methods
|
||||
onMouseEnter() { this.highlight("yellow"); }
|
||||
onMouseEnter() { this.highlight('yellow'); }
|
||||
onMouseLeave() { this.highlight(null); }
|
||||
|
||||
private highlight(color: string) {
|
||||
|
||||
@@ -13,12 +13,12 @@ import { Directive, ElementRef, Input } from '@angular/core';
|
||||
export class HighlightDirective {
|
||||
private _defaultColor = 'red';
|
||||
private el: HTMLElement;
|
||||
|
||||
|
||||
constructor(el: ElementRef) { this.el = el.nativeElement; }
|
||||
// #enddocregion class-1
|
||||
|
||||
// #docregion defaultColor
|
||||
@Input() set defaultColor(colorName:string){
|
||||
@Input() set defaultColor(colorName: string){
|
||||
this._defaultColor = colorName || this._defaultColor;
|
||||
}
|
||||
// #enddocregion defaultColor
|
||||
@@ -33,7 +33,7 @@ export class HighlightDirective {
|
||||
// #enddocregion mouse-enter
|
||||
onMouseLeave() { this.highlight(null); }
|
||||
|
||||
private highlight(color:string) {
|
||||
private highlight(color: string) {
|
||||
this.el.style.backgroundColor = color;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ describe('Angular 1 to 2 Quick Reference Tests', function () {
|
||||
|
||||
posterButton.click().then(function () {
|
||||
testImagesAreDisplayed(isDisplayed);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function getMovieRows() {
|
||||
@@ -107,7 +107,7 @@ describe('Angular 1 to 2 Quick Reference Tests', function () {
|
||||
} else {
|
||||
expect(favoriteHeroLabel.isDisplayed()).toBe(false);
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -11,7 +11,7 @@ import { StringSafeDatePipe } from './date.pipe';
|
||||
// #docregion component
|
||||
@Component({
|
||||
selector: 'movie-list',
|
||||
templateUrl:'app/movie-list.component.html',
|
||||
templateUrl: 'app/movie-list.component.html',
|
||||
// #enddocregion component
|
||||
// #docregion style-url
|
||||
styleUrls: ['app/movie-list.component.css'],
|
||||
|
||||
@@ -20,8 +20,8 @@ describe('Component Communication Cookbook Tests', function () {
|
||||
for (let i = 0; i < _heroNames.length; i++) {
|
||||
let childTitle = heroes.get(i).element(by.tagName('h3')).getText();
|
||||
let childDetail = heroes.get(i).element(by.tagName('p')).getText();
|
||||
expect(childTitle).toEqual(_heroNames[i] + ' says:')
|
||||
expect(childDetail).toContain(_masterName)
|
||||
expect(childTitle).toEqual(_heroNames[i] + ' says:');
|
||||
expect(childDetail).toContain(_masterName);
|
||||
}
|
||||
});
|
||||
// ...
|
||||
@@ -38,7 +38,7 @@ describe('Component Communication Cookbook Tests', function () {
|
||||
let hero = parent.all(by.tagName('name-child')).get(_nonEmptyNameIndex);
|
||||
|
||||
let displayName = hero.element(by.tagName('h3')).getText();
|
||||
expect(displayName).toEqual(_nonEmptyName)
|
||||
expect(displayName).toEqual(_nonEmptyName);
|
||||
});
|
||||
|
||||
it('should replace empty name with default name', function () {
|
||||
@@ -48,7 +48,7 @@ describe('Component Communication Cookbook Tests', function () {
|
||||
let hero = parent.all(by.tagName('name-child')).get(_emptyNameIndex);
|
||||
|
||||
let displayName = hero.element(by.tagName('h3')).getText();
|
||||
expect(displayName).toEqual(_defaultName)
|
||||
expect(displayName).toEqual(_defaultName);
|
||||
});
|
||||
// ...
|
||||
// #enddocregion parent-to-child-setter
|
||||
@@ -83,7 +83,7 @@ describe('Component Communication Cookbook Tests', function () {
|
||||
expect(actual.label).toBe(labelAfter2Minor);
|
||||
expect(actual.count).toBe(3);
|
||||
expect(actual.logs.get(2).getText()).toBe(logAfter2Minor);
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -155,11 +155,11 @@ describe('Component Communication Cookbook Tests', function () {
|
||||
// Can't run timer tests in protractor because
|
||||
// interaction w/ zones causes all tests to freeze & timeout.
|
||||
xdescribe('Parent calls child via local var', function() {
|
||||
countDownTimerTests('countdown-parent-lv')
|
||||
countDownTimerTests('countdown-parent-lv');
|
||||
});
|
||||
|
||||
xdescribe('Parent calls ViewChild', function() {
|
||||
countDownTimerTests('countdown-parent-vc')
|
||||
countDownTimerTests('countdown-parent-vc');
|
||||
});
|
||||
|
||||
function countDownTimerTests(parentTag: string) {
|
||||
|
||||
@@ -19,7 +19,7 @@ let directives: any[] = [
|
||||
// Include Countdown examples
|
||||
// unless in e2e tests which they break.
|
||||
if (!/e2e/.test(location.search)) {
|
||||
console.log('adding countdown timer examples')
|
||||
console.log('adding countdown timer examples');
|
||||
directives.push(CountdownLocalVarParentComponent);
|
||||
directives.push(CountdownViewChildParentComponent);
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ import { Subscription } from 'rxjs/Subscription';
|
||||
</p>
|
||||
`
|
||||
})
|
||||
export class AstronautComponent implements OnDestroy{
|
||||
export class AstronautComponent implements OnDestroy {
|
||||
@Input() astronaut: string;
|
||||
mission = "<no mission announced>";
|
||||
mission = '<no mission announced>';
|
||||
confirmed = false;
|
||||
announced = false;
|
||||
subscription:Subscription;
|
||||
subscription: Subscription;
|
||||
|
||||
constructor(private missionService: MissionService) {
|
||||
this.subscription = missionService.missionAnnounced$.subscribe(
|
||||
@@ -30,7 +30,7 @@ export class AstronautComponent implements OnDestroy{
|
||||
this.mission = mission;
|
||||
this.announced = true;
|
||||
this.confirmed = false;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
confirm() {
|
||||
@@ -38,9 +38,9 @@ export class AstronautComponent implements OnDestroy{
|
||||
this.missionService.confirmMission(this.astronaut);
|
||||
}
|
||||
|
||||
ngOnDestroy(){
|
||||
ngOnDestroy() {
|
||||
// prevent memory leak when component destroyed
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
// #enddocregion
|
||||
// #enddocregion
|
||||
|
||||
+5
-5
@@ -11,7 +11,7 @@ import { CountdownTimerComponent } from './countdown-timer.component';
|
||||
//// Local variable, #timer, version
|
||||
// #docregion lv
|
||||
@Component({
|
||||
selector:'countdown-parent-lv',
|
||||
selector: 'countdown-parent-lv',
|
||||
template: `
|
||||
<h3>Countdown to Liftoff (via local variable)</h3>
|
||||
<button (click)="timer.start()">Start</button>
|
||||
@@ -28,7 +28,7 @@ export class CountdownLocalVarParentComponent { }
|
||||
//// View Child version
|
||||
// #docregion vc
|
||||
@Component({
|
||||
selector:'countdown-parent-vc',
|
||||
selector: 'countdown-parent-vc',
|
||||
template: `
|
||||
<h3>Countdown to Liftoff (via ViewChild)</h3>
|
||||
<button (click)="start()">Start</button>
|
||||
@@ -42,7 +42,7 @@ export class CountdownLocalVarParentComponent { }
|
||||
export class CountdownViewChildParentComponent implements AfterViewInit {
|
||||
|
||||
@ViewChild(CountdownTimerComponent)
|
||||
private timerComponent:CountdownTimerComponent;
|
||||
private timerComponent: CountdownTimerComponent;
|
||||
|
||||
seconds() { return 0; }
|
||||
|
||||
@@ -50,10 +50,10 @@ export class CountdownViewChildParentComponent implements AfterViewInit {
|
||||
// Redefine `seconds()` to get from the `CountdownTimerComponent.seconds` ...
|
||||
// but wait a tick first to avoid one-time devMode
|
||||
// unidirectional-data-flow-violation error
|
||||
setTimeout(() => this.seconds = () => this.timerComponent.seconds, 0)
|
||||
setTimeout(() => this.seconds = () => this.timerComponent.seconds, 0);
|
||||
}
|
||||
|
||||
start(){ this.timerComponent.start(); }
|
||||
start() { this.timerComponent.start(); }
|
||||
stop() { this.timerComponent.stop(); }
|
||||
}
|
||||
// #enddocregion vc
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ export class CountdownTimerComponent implements OnInit, OnDestroy {
|
||||
message = '';
|
||||
seconds = 11;
|
||||
|
||||
clearTimer() {clearInterval(this.intervalId);}
|
||||
clearTimer() { clearInterval(this.intervalId); }
|
||||
|
||||
ngOnInit() { this.start(); }
|
||||
ngOnDestroy() { this.clearTimer(); }
|
||||
|
||||
@@ -6,4 +6,4 @@ export const HEROES = [
|
||||
{name: 'Mr. IQ'},
|
||||
{name: 'Magneta'},
|
||||
{name: 'Bombasto'}
|
||||
];
|
||||
];
|
||||
|
||||
@@ -2,4 +2,4 @@ import { bootstrap } from '@angular/platform-browser-dynamic';
|
||||
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
bootstrap(AppComponent);
|
||||
bootstrap(AppComponent);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// #docregion
|
||||
import { Injectable } from '@angular/core'
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
|
||||
@Injectable()
|
||||
@@ -15,7 +15,7 @@ export class MissionService {
|
||||
|
||||
// Service message commands
|
||||
announceMission(mission: string) {
|
||||
this.missionAnnouncedSource.next(mission)
|
||||
this.missionAnnouncedSource.next(mission);
|
||||
}
|
||||
|
||||
confirmMission(astronaut: string) {
|
||||
|
||||
@@ -21,7 +21,7 @@ import { MissionService } from './mission.service';
|
||||
providers: [MissionService]
|
||||
})
|
||||
export class MissionControlComponent {
|
||||
astronauts = ['Lovell', 'Swigert', 'Haise']
|
||||
astronauts = ['Lovell', 'Swigert', 'Haise'];
|
||||
history: string[] = [];
|
||||
missions = ['Fly to the moon!',
|
||||
'Fly to mars!',
|
||||
@@ -32,7 +32,7 @@ export class MissionControlComponent {
|
||||
missionService.missionConfirmed$.subscribe(
|
||||
astronaut => {
|
||||
this.history.push(`${astronaut} confirmed the mission`);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
announce() {
|
||||
|
||||
@@ -17,7 +17,7 @@ export class VersionChildComponent implements OnChanges {
|
||||
@Input() minor: number;
|
||||
changeLog: string[] = [];
|
||||
|
||||
ngOnChanges(changes: {[propKey:string]: SimpleChange}){
|
||||
ngOnChanges(changes: {[propKey: string]: SimpleChange}) {
|
||||
let log: string[] = [];
|
||||
for (let propName in changes) {
|
||||
let changedProp = changes[propName];
|
||||
|
||||
@@ -14,9 +14,9 @@ export class VoterComponent {
|
||||
@Output() onVoted = new EventEmitter<boolean>();
|
||||
voted = false;
|
||||
|
||||
vote(agreed:boolean){
|
||||
vote(agreed: boolean) {
|
||||
this.onVoted.emit(agreed);
|
||||
this.voted = true;
|
||||
}
|
||||
}
|
||||
// #enddocregion
|
||||
// #enddocregion
|
||||
|
||||
@@ -18,7 +18,7 @@ import { VoterComponent } from './voter.component';
|
||||
export class VoteTakerComponent {
|
||||
agreed = 0;
|
||||
disagreed = 0;
|
||||
voters = ['Mr. IQ', 'Ms. Universe', 'Bombasto']
|
||||
voters = ['Mr. IQ', 'Ms. Universe', 'Bombasto'];
|
||||
|
||||
onVoted(agreed: boolean) {
|
||||
agreed ? this.agreed++ : this.disagreed++;
|
||||
|
||||
@@ -12,7 +12,7 @@ describe('Cookbook: component-relative paths', function () {
|
||||
title: element( by.tagName( 'h1' )),
|
||||
absComp: element( by.css( 'absolute-path div' ) ),
|
||||
relComp: element( by.css( 'relative-path div' ) )
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let page: Page;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// #docregion
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
import { SomeAbsoluteComponent, SomeRelativeComponent} from './some.component';
|
||||
import { SomeAbsoluteComponent, SomeRelativeComponent } from './some.component';
|
||||
|
||||
@Component({
|
||||
selector: 'my-app',
|
||||
|
||||
@@ -66,7 +66,7 @@ describe('Dependency Injection Cookbook', function () {
|
||||
});
|
||||
|
||||
it('should highlight Hero Bios and Contacts container when mouseover', function () {
|
||||
let target = element(by.css('div[myHighlight="yellow"]'))
|
||||
let target = element(by.css('div[myHighlight="yellow"]'));
|
||||
let yellow = 'rgba(255, 255, 0, 1)';
|
||||
|
||||
expect(target.getCssValue('background-color')).not.toEqual(yellow);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
import { HeroBiosComponent,
|
||||
HeroBiosAndContactsComponent} from './hero-bios.component';
|
||||
HeroBiosAndContactsComponent } from './hero-bios.component';
|
||||
import { HeroOfTheMonthComponent } from './hero-of-the-month.component';
|
||||
import { HeroesBaseComponent,
|
||||
SortedHeroesComponent } from './sorted-heroes.component';
|
||||
|
||||
@@ -6,9 +6,9 @@ import { HeroCacheService } from './hero-cache.service';
|
||||
|
||||
// #docregion component
|
||||
@Component({
|
||||
selector:'hero-bio',
|
||||
selector: 'hero-bio',
|
||||
// #docregion template
|
||||
template:`
|
||||
template: `
|
||||
<h4>{{hero.name}}</h4>
|
||||
<ng-content></ng-content>
|
||||
<textarea cols="25" [(ngModel)]="hero.description"></textarea>`,
|
||||
@@ -18,9 +18,9 @@ import { HeroCacheService } from './hero-cache.service';
|
||||
|
||||
export class HeroBioComponent implements OnInit {
|
||||
|
||||
@Input() heroId:number;
|
||||
@Input() heroId: number;
|
||||
|
||||
constructor(private heroCache:HeroCacheService) { }
|
||||
constructor(private heroCache: HeroCacheService) { }
|
||||
|
||||
ngOnInit() { this.heroCache.fetchCachedHero(this.heroId); }
|
||||
|
||||
|
||||
@@ -10,15 +10,15 @@ import { LoggerService } from './logger.service';
|
||||
//////// HeroBiosComponent ////
|
||||
// #docregion simple
|
||||
@Component({
|
||||
selector:'hero-bios',
|
||||
template:`
|
||||
selector: 'hero-bios',
|
||||
template: `
|
||||
<hero-bio [heroId]="1"></hero-bio>
|
||||
<hero-bio [heroId]="2"></hero-bio>
|
||||
<hero-bio [heroId]="3"></hero-bio>`,
|
||||
directives:[HeroBioComponent],
|
||||
directives: [HeroBioComponent],
|
||||
providers: [HeroService]
|
||||
})
|
||||
export class HeroBiosComponent{
|
||||
export class HeroBiosComponent {
|
||||
// #enddocregion simple
|
||||
// #docregion ctor
|
||||
constructor(logger: LoggerService) {
|
||||
@@ -32,21 +32,21 @@ export class HeroBiosComponent{
|
||||
//////// HeroBiosAndContactsComponent ////
|
||||
// #docregion hero-bios-and-contacts
|
||||
@Component({
|
||||
selector:'hero-bios-and-contacts',
|
||||
selector: 'hero-bios-and-contacts',
|
||||
// #docregion template
|
||||
template:`
|
||||
template: `
|
||||
<hero-bio [heroId]="1"> <hero-contact></hero-contact> </hero-bio>
|
||||
<hero-bio [heroId]="2"> <hero-contact></hero-contact> </hero-bio>
|
||||
<hero-bio [heroId]="3"> <hero-contact></hero-contact> </hero-bio>`,
|
||||
// #enddocregion template
|
||||
directives:[HeroBioComponent, HeroContactComponent],
|
||||
directives: [HeroBioComponent, HeroContactComponent],
|
||||
// #docregion class-provider
|
||||
providers: [HeroService]
|
||||
// #enddocregion class-provider
|
||||
})
|
||||
export class HeroBiosAndContactsComponent{
|
||||
export class HeroBiosAndContactsComponent {
|
||||
constructor(logger: LoggerService) {
|
||||
logger.logInfo('Creating HeroBiosAndContactsComponent');
|
||||
}
|
||||
}
|
||||
// #enddocregion hero-bios-and-contacts
|
||||
// #enddocregion hero-bios-and-contacts
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user