refactor(docs-infra): fix docs examples for tslint rules related to object properties (#38143)
This commit updates the docs examples to be compatible with the `no-string-literal`, `object-literal-key-quotes` and `object-literal-shorthand` tslint rules. This is in preparation of updating the docs examples `tslint.json` to match the one generated for new Angular CLI apps in a future commit. PR Close #38143
This commit is contained in:
parent
fc709423f2
commit
8aa29438ac
|
@ -34,7 +34,7 @@ export class AppComponent {
|
|||
|
||||
// #docregion prepare-router-outlet
|
||||
prepareRoute(outlet: RouterOutlet) {
|
||||
return outlet && outlet.activatedRouteData && outlet.activatedRouteData['animation'];
|
||||
return outlet && outlet.activatedRouteData && outlet.activatedRouteData.animation;
|
||||
}
|
||||
|
||||
// #enddocregion prepare-router-outlet
|
||||
|
|
|
@ -46,9 +46,9 @@ export class AppComponent implements OnInit {
|
|||
setCurrentClasses() {
|
||||
// CSS classes: added/removed per current state of component properties
|
||||
this.currentClasses = {
|
||||
'saveable': this.canSave,
|
||||
'modified': !this.isUnchanged,
|
||||
'special': this.isSpecial
|
||||
saveable: this.canSave,
|
||||
modified: !this.isUnchanged,
|
||||
special: this.isSpecial
|
||||
};
|
||||
}
|
||||
// #enddocregion setClasses
|
||||
|
@ -107,7 +107,7 @@ export class AppComponent implements OnInit {
|
|||
trackByItems(index: number, item: Item): number { return item.id; }
|
||||
// #enddocregion trackByItems
|
||||
|
||||
trackById(index: number, item: any): number { return item['id']; }
|
||||
trackById(index: number, item: any): number { return item.id; }
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -111,8 +111,8 @@ describe('Component Communication Cookbook Tests', () => {
|
|||
let logs = ul.all(by.tagName('li'));
|
||||
|
||||
return {
|
||||
label: label,
|
||||
logs: logs,
|
||||
label,
|
||||
logs,
|
||||
count: logs.count()
|
||||
};
|
||||
}
|
||||
|
|
|
@ -49,6 +49,6 @@ if (!/e2e/.test(location.search)) {
|
|||
],
|
||||
declarations: directives,
|
||||
bootstrap: [ AppComponent ],
|
||||
schemas: schemas
|
||||
schemas
|
||||
})
|
||||
export class AppModule { }
|
||||
|
|
|
@ -18,7 +18,7 @@ const template = '{{log}}';
|
|||
|
||||
@Component({
|
||||
selector: 'provider-1',
|
||||
template: template,
|
||||
template,
|
||||
// #docregion providers-1, providers-logger
|
||||
providers: [Logger]
|
||||
// #enddocregion providers-1, providers-logger
|
||||
|
@ -35,7 +35,7 @@ export class Provider1Component {
|
|||
|
||||
@Component({
|
||||
selector: 'provider-3',
|
||||
template: template,
|
||||
template,
|
||||
providers:
|
||||
// #docregion providers-3
|
||||
[{ provide: Logger, useClass: Logger }]
|
||||
|
@ -54,7 +54,7 @@ export class BetterLogger extends Logger {}
|
|||
|
||||
@Component({
|
||||
selector: 'provider-4',
|
||||
template: template,
|
||||
template,
|
||||
providers:
|
||||
// #docregion providers-4
|
||||
[{ provide: Logger, useClass: BetterLogger }]
|
||||
|
@ -84,7 +84,7 @@ export class EvenBetterLogger extends Logger {
|
|||
|
||||
@Component({
|
||||
selector: 'provider-5',
|
||||
template: template,
|
||||
template,
|
||||
providers:
|
||||
// #docregion providers-5
|
||||
[ UserService,
|
||||
|
@ -112,7 +112,7 @@ export class OldLogger {
|
|||
|
||||
@Component({
|
||||
selector: 'provider-6a',
|
||||
template: template,
|
||||
template,
|
||||
providers:
|
||||
// #docregion providers-6a
|
||||
[ NewLogger,
|
||||
|
@ -135,7 +135,7 @@ export class Provider6aComponent {
|
|||
|
||||
@Component({
|
||||
selector: 'provider-6b',
|
||||
template: template,
|
||||
template,
|
||||
providers:
|
||||
// #docregion providers-6b
|
||||
[ NewLogger,
|
||||
|
@ -168,7 +168,7 @@ export const SilentLogger = {
|
|||
|
||||
@Component({
|
||||
selector: 'provider-7',
|
||||
template: template,
|
||||
template,
|
||||
providers:
|
||||
// #docregion providers-7
|
||||
[{ provide: Logger, useValue: SilentLogger }]
|
||||
|
@ -186,7 +186,7 @@ export class Provider7Component {
|
|||
|
||||
@Component({
|
||||
selector: 'provider-8',
|
||||
template: template,
|
||||
template,
|
||||
providers: [heroServiceProvider, Logger, UserService]
|
||||
})
|
||||
export class Provider8Component {
|
||||
|
@ -202,7 +202,7 @@ export class Provider8Component {
|
|||
|
||||
@Component({
|
||||
selector: 'provider-9',
|
||||
template: template,
|
||||
template,
|
||||
/*
|
||||
// #docregion providers-9-interface
|
||||
// FAIL! Can't use interface as provider token
|
||||
|
@ -241,7 +241,7 @@ let some_message = 'Hello from the injected logger';
|
|||
|
||||
@Component({
|
||||
selector: 'provider-10',
|
||||
template: template,
|
||||
template,
|
||||
providers: [{ provide: Logger, useValue: null }]
|
||||
})
|
||||
export class Provider10Component implements OnInit {
|
||||
|
|
|
@ -10,13 +10,14 @@ export class QuestionBase<T> {
|
|||
options: {key: string, value: string}[];
|
||||
|
||||
constructor(options: {
|
||||
value?: T,
|
||||
key?: string,
|
||||
label?: string,
|
||||
required?: boolean,
|
||||
order?: number,
|
||||
controlType?: string,
|
||||
type?: string
|
||||
value?: T;
|
||||
key?: string;
|
||||
label?: string;
|
||||
required?: boolean;
|
||||
order?: number;
|
||||
controlType?: string;
|
||||
type?: string;
|
||||
options?: {key: string, value: string}[];
|
||||
} = {}) {
|
||||
this.value = options.value;
|
||||
this.key = options.key || '';
|
||||
|
@ -25,5 +26,6 @@ export class QuestionBase<T> {
|
|||
this.order = options.order === undefined ? 1 : options.order;
|
||||
this.controlType = options.controlType || '';
|
||||
this.type = options.type || '';
|
||||
this.options = options.options || [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,4 @@ import { QuestionBase } from './question-base';
|
|||
|
||||
export class DropdownQuestion extends QuestionBase<string> {
|
||||
controlType = 'dropdown';
|
||||
options: {key: string, value: string}[] = [];
|
||||
|
||||
constructor(options: {} = {}) {
|
||||
super(options);
|
||||
this.options = options['options'] || [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,4 @@ import { QuestionBase } from './question-base';
|
|||
|
||||
export class TextboxQuestion extends QuestionBase<string> {
|
||||
controlType = 'textbox';
|
||||
type: string;
|
||||
|
||||
constructor(options: {} = {}) {
|
||||
super(options);
|
||||
this.type = options['type'] || '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ function getPage(sectionTag: string) {
|
|||
let buttons = section.all(by.css('button'));
|
||||
|
||||
page = {
|
||||
section: section,
|
||||
section,
|
||||
form: section.element(by.css('form')),
|
||||
title: section.element(by.css('h1')),
|
||||
nameInput: section.element(by.css('#name')),
|
||||
|
|
|
@ -22,13 +22,13 @@ export class HeroFormReactiveComponent implements OnInit {
|
|||
ngOnInit(): void {
|
||||
// #docregion custom-validator
|
||||
this.heroForm = new FormGroup({
|
||||
'name': new FormControl(this.hero.name, [
|
||||
name: new FormControl(this.hero.name, [
|
||||
Validators.required,
|
||||
Validators.minLength(4),
|
||||
forbiddenNameValidator(/bob/i) // <-- Here's how you pass in the custom validator.
|
||||
]),
|
||||
'alterEgo': new FormControl(this.hero.alterEgo),
|
||||
'power': new FormControl(this.hero.power, Validators.required)
|
||||
alterEgo: new FormControl(this.hero.alterEgo),
|
||||
power: new FormControl(this.hero.power, Validators.required)
|
||||
});
|
||||
// #enddocregion custom-validator
|
||||
|
||||
|
|
|
@ -22,16 +22,16 @@ export class HeroFormReactiveComponent implements OnInit {
|
|||
ngOnInit(): void {
|
||||
// #docregion async-validation
|
||||
this.heroForm = new FormGroup({
|
||||
'name': new FormControl(this.hero.name, [
|
||||
name: new FormControl(this.hero.name, [
|
||||
Validators.required,
|
||||
Validators.minLength(4),
|
||||
forbiddenNameValidator(/bob/i)
|
||||
]),
|
||||
'alterEgo': new FormControl(this.hero.alterEgo, {
|
||||
alterEgo: new FormControl(this.hero.alterEgo, {
|
||||
asyncValidators: [this.alterEgoValidator.validate.bind(this.alterEgoValidator)],
|
||||
updateOn: 'blur'
|
||||
}),
|
||||
'power': new FormControl(this.hero.power, Validators.required)
|
||||
power: new FormControl(this.hero.power, Validators.required)
|
||||
});
|
||||
// #enddocregion async-validation
|
||||
}
|
||||
|
|
|
@ -21,16 +21,16 @@ export class HeroFormReactiveComponent implements OnInit {
|
|||
|
||||
ngOnInit(): void {
|
||||
this.heroForm = new FormGroup({
|
||||
'name': new FormControl(this.hero.name, [
|
||||
name: new FormControl(this.hero.name, [
|
||||
Validators.required,
|
||||
Validators.minLength(4),
|
||||
forbiddenNameValidator(/bob/i)
|
||||
]),
|
||||
'alterEgo': new FormControl(this.hero.alterEgo, {
|
||||
alterEgo: new FormControl(this.hero.alterEgo, {
|
||||
asyncValidators: [this.alterEgoValidator.validate.bind(this.alterEgoValidator)],
|
||||
updateOn: 'blur'
|
||||
}),
|
||||
'power': new FormControl(this.hero.power, Validators.required)
|
||||
power: new FormControl(this.hero.power, Validators.required)
|
||||
}, { validators: identityRevealedValidator }); // <-- add custom validator at the FormGroup level
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import { AbstractControl, NG_VALIDATORS, Validator, ValidatorFn, Validators } fr
|
|||
export function forbiddenNameValidator(nameRe: RegExp): ValidatorFn {
|
||||
return (control: AbstractControl): {[key: string]: any} | null => {
|
||||
const forbidden = nameRe.test(control.value);
|
||||
return forbidden ? {'forbiddenName': {value: control.value}} : null;
|
||||
return forbidden ? {forbiddenName: {value: control.value}} : null;
|
||||
};
|
||||
}
|
||||
// #enddocregion custom-validator
|
||||
|
|
|
@ -8,7 +8,7 @@ export const identityRevealedValidator: ValidatorFn = (control: FormGroup): Vali
|
|||
const name = control.get('name');
|
||||
const alterEgo = control.get('alterEgo');
|
||||
|
||||
return name && alterEgo && name.value === alterEgo.value ? { 'identityRevealed': true } : null;
|
||||
return name && alterEgo && name.value === alterEgo.value ? { identityRevealed: true } : null;
|
||||
};
|
||||
// #enddocregion cross-validation-validator
|
||||
|
||||
|
|
|
@ -48,9 +48,9 @@ export class HeroFormComponent {
|
|||
// Reveal in html:
|
||||
// Name via form.controls = {{showFormControls(heroForm)}}
|
||||
showFormControls(form: any) {
|
||||
return form && form.controls['name'] &&
|
||||
return form && form.controls.name &&
|
||||
// #docregion form-controls
|
||||
form.controls['name'].value; // Dr. IQ
|
||||
form.controls.name.value; // Dr. IQ
|
||||
// #enddocregion form-controls
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ export class ConfigComponent {
|
|||
this.configService.getConfig_1()
|
||||
// #docregion v1, v1_callback
|
||||
.subscribe((data: Config) => this.config = {
|
||||
heroesUrl: data['heroesUrl'],
|
||||
textfile: data['textfile']
|
||||
heroesUrl: data.heroesUrl,
|
||||
textfile: data.textfile
|
||||
});
|
||||
// #enddocregion v1_callback
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import { HttpErrorHandler, HandleError } from '../http-error-handler.service';
|
|||
const httpOptions = {
|
||||
headers: new HttpHeaders({
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'my-auth-token'
|
||||
Authorization: 'my-auth-token'
|
||||
})
|
||||
};
|
||||
// #enddocregion http-options
|
||||
|
|
|
@ -22,13 +22,13 @@ import './testing/http-client.spec.ts';
|
|||
bootstrap();
|
||||
|
||||
//
|
||||
function bootstrap () {
|
||||
if (window['jasmineRef']) {
|
||||
function bootstrap() {
|
||||
if ((window as any).jasmineRef) {
|
||||
location.reload();
|
||||
return;
|
||||
} else {
|
||||
window.onload(undefined);
|
||||
window['jasmineRef'] = jasmine.getEnv();
|
||||
(window as any).jasmineRef = jasmine.getEnv();
|
||||
}
|
||||
|
||||
// First, initialize the Angular testing environment.
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
import jasmineRequire from 'jasmine-core/lib/jasmine-core/jasmine.js';
|
||||
|
||||
window['jasmineRequire'] = jasmineRequire;
|
||||
(window as any).jasmineRequire = jasmineRequire;
|
||||
|
|
|
@ -73,7 +73,7 @@ describe('HttpClient testing', () => {
|
|||
|
||||
// Make an HTTP GET request with specific header
|
||||
httpClient.get<Data>(testUrl, {
|
||||
headers: new HttpHeaders({'Authorization': 'my-auth-token'})
|
||||
headers: new HttpHeaders({Authorization: 'my-auth-token'})
|
||||
})
|
||||
.subscribe(data =>
|
||||
expect(data).toEqual(testData)
|
||||
|
|
|
@ -31,7 +31,7 @@ export class MyCounterComponent implements OnChanges {
|
|||
}
|
||||
|
||||
// A change to `counter` is the only change we care about
|
||||
let chng = changes['counter'];
|
||||
let chng = changes.counter;
|
||||
let cur = chng.currentValue;
|
||||
let prev = JSON.stringify(chng.previousValue); // first time is {}; after is integer
|
||||
this.changeLog.push(`counter: currentValue = ${cur}, previousValue = ${prev}`);
|
||||
|
|
|
@ -57,7 +57,7 @@ export class PeekABooComponent extends PeekABooDirective implements
|
|||
let changesMsgs: string[] = [];
|
||||
for (let propName in changes) {
|
||||
if (propName === 'name') {
|
||||
let name = changes['name'].currentValue;
|
||||
let name = changes.name.currentValue;
|
||||
changesMsgs.push(`name ${this.verb} to "${name}"`);
|
||||
} else {
|
||||
changesMsgs.push(propName + ' ' + this.verb);
|
||||
|
|
|
@ -20,12 +20,12 @@ describe('Router', () => {
|
|||
|
||||
crisisHref: hrefEles.get(0),
|
||||
crisisList: element.all(by.css('app-root > div > app-crisis-center > app-crisis-list li')),
|
||||
crisisDetail: crisisDetail,
|
||||
crisisDetail,
|
||||
crisisDetailTitle: crisisDetail.element(by.xpath('*[1]')),
|
||||
|
||||
heroesHref: hrefEles.get(1),
|
||||
heroesList: element.all(by.css('app-root > div > app-hero-list li')),
|
||||
heroDetail: heroDetail,
|
||||
heroDetail,
|
||||
heroDetailTitle: heroDetail.element(by.xpath('*[2]')),
|
||||
|
||||
adminHref: hrefEles.get(2),
|
||||
|
|
|
@ -15,7 +15,7 @@ import { slideInAnimation } from './animations';
|
|||
// #docregion function-binding
|
||||
export class AppComponent {
|
||||
getAnimationData(outlet: RouterOutlet) {
|
||||
return outlet && outlet.activatedRouteData && outlet.activatedRouteData['animation'];
|
||||
return outlet && outlet.activatedRouteData && outlet.activatedRouteData.animation;
|
||||
}
|
||||
}
|
||||
// #enddocregion function-binding
|
||||
|
|
|
@ -12,6 +12,6 @@ import { slideInAnimation } from './animations';
|
|||
})
|
||||
export class AppComponent {
|
||||
getAnimationData(outlet: RouterOutlet) {
|
||||
return outlet && outlet.activatedRouteData && outlet.activatedRouteData['animation'];
|
||||
return outlet && outlet.activatedRouteData && outlet.activatedRouteData.animation;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ export class AuthGuard implements CanActivate, CanActivateChild {
|
|||
// Set our navigation extras object
|
||||
// that contains our global query params and fragment
|
||||
let navigationExtras: NavigationExtras = {
|
||||
queryParams: { 'session_id': sessionId },
|
||||
queryParams: { session_id: sessionId },
|
||||
fragment: 'anchor'
|
||||
};
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ export class AuthGuard implements CanActivate, CanActivateChild, CanLoad {
|
|||
// Set our navigation extras object
|
||||
// that contains our global query params and fragment
|
||||
let navigationExtras: NavigationExtras = {
|
||||
queryParams: { 'session_id': sessionId },
|
||||
queryParams: { session_id: sessionId },
|
||||
fragment: 'anchor'
|
||||
};
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ export class SelectivePreloadingStrategyService implements PreloadingStrategy {
|
|||
preloadedModules: string[] = [];
|
||||
|
||||
preload(route: Route, load: () => Observable<any>): Observable<any> {
|
||||
if (route.data && route.data['preload']) {
|
||||
if (route.data && route.data.preload) {
|
||||
// add the route path to the preloaded module array
|
||||
this.preloadedModules.push(route.path);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ describe('Testing Example', () => {
|
|||
let navElts = element.all(by.css('app-root nav a'));
|
||||
|
||||
return {
|
||||
navElts: navElts,
|
||||
navElts,
|
||||
|
||||
appDashboard: element(by.css('app-root app-dashboard')),
|
||||
};
|
||||
|
|
|
@ -222,7 +222,7 @@ describe('demo (with TestBed):', () => {
|
|||
fixture.detectChanges();
|
||||
const ngForRow = fixture.debugElement.query(By.directive(IoComponent)); // first hero ngForRow
|
||||
|
||||
const hero = ngForRow.context['hero']; // the hero object passed into the row
|
||||
const hero = ngForRow.context.hero; // the hero object passed into the row
|
||||
expect(hero.name).toBe(heroName, 'ngRow.context.hero');
|
||||
|
||||
const rowComp = ngForRow.componentInstance;
|
||||
|
@ -514,11 +514,11 @@ describe('demo (with TestBed):', () => {
|
|||
expect(comp.children.toArray().length).toBe(4,
|
||||
'three different child components and an ElementRef with #content');
|
||||
|
||||
expect(el.references['nc']).toBe(comp, '#nc reference to component');
|
||||
expect(el.references.nc).toBe(comp, '#nc reference to component');
|
||||
|
||||
// #docregion custom-predicate
|
||||
// Filter for DebugElements with a #content reference
|
||||
const contentRefs = el.queryAll( de => de.references['content']);
|
||||
const contentRefs = el.queryAll( de => de.references.content);
|
||||
// #enddocregion custom-predicate
|
||||
expect(contentRefs.length).toBe(4, 'elements w/ a #content reference');
|
||||
});
|
||||
|
|
|
@ -72,7 +72,7 @@ describe('HttpClient testing', () => {
|
|||
|
||||
// Make an HTTP GET request with specific header
|
||||
httpClient.get<Data>(testUrl, {
|
||||
headers: new HttpHeaders({'Authorization': 'my-auth-token'})
|
||||
headers: new HttpHeaders({Authorization: 'my-auth-token'})
|
||||
})
|
||||
.subscribe(data =>
|
||||
expect(data).toEqual(testData)
|
||||
|
|
|
@ -7,7 +7,7 @@ describe('CanvasComponent', () => {
|
|||
// #enddocregion without-toBlob-macrotask
|
||||
// #docregion enable-toBlob-macrotask
|
||||
beforeEach(() => {
|
||||
window['__zone_symbol__FakeAsyncTestMacroTask'] = [
|
||||
(window as any).__zone_symbol__FakeAsyncTestMacroTask = [
|
||||
{
|
||||
source: 'HTMLCanvasElement.toBlob',
|
||||
callbackArgs: [{ size: 200 }],
|
||||
|
|
|
@ -69,7 +69,7 @@ describe('HighlightDirective', () => {
|
|||
|
||||
|
||||
it('bare <h2> should not have a customProperty', () => {
|
||||
expect(bareH2.properties['customProperty']).toBeUndefined();
|
||||
expect(bareH2.properties.customProperty).toBeUndefined();
|
||||
});
|
||||
// #enddocregion selected-tests
|
||||
|
||||
|
|
|
@ -23,13 +23,13 @@ bootstrap();
|
|||
|
||||
//
|
||||
|
||||
function bootstrap () {
|
||||
if (window['jasmineRef']) {
|
||||
function bootstrap() {
|
||||
if ((window as any).jasmineRef) {
|
||||
location.reload();
|
||||
return;
|
||||
} else {
|
||||
window.onload(undefined);
|
||||
window['jasmineRef'] = jasmine.getEnv();
|
||||
(window as any).jasmineRef = jasmine.getEnv();
|
||||
}
|
||||
|
||||
// First, initialize the Angular testing environment.
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
import jasmineRequire from 'jasmine-core/lib/jasmine-core/jasmine.js';
|
||||
|
||||
window['jasmineRequire'] = jasmineRequire;
|
||||
(window as any).jasmineRequire = jasmineRequire;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
export function addMatchers(): void {
|
||||
jasmine.addMatchers({
|
||||
toHaveText: toHaveText
|
||||
toHaveText
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ describe('Tutorial part 5', () => {
|
|||
let navElts = element.all(by.css('app-root nav a'));
|
||||
|
||||
return {
|
||||
navElts: navElts,
|
||||
navElts,
|
||||
|
||||
appDashboardHref: navElts.get(0),
|
||||
appDashboard: element(by.css('app-root app-dashboard')),
|
||||
|
|
|
@ -50,7 +50,7 @@ describe('Tutorial part 6', () => {
|
|||
let navElts = element.all(by.css('app-root nav a'));
|
||||
|
||||
return {
|
||||
navElts: navElts,
|
||||
navElts,
|
||||
|
||||
appDashboardHref: navElts.get(0),
|
||||
appDashboard: element(by.css('app-root app-dashboard')),
|
||||
|
|
|
@ -19,7 +19,7 @@ describe('phoneDetail', () => {
|
|||
$httpBackend = _$httpBackend_;
|
||||
$httpBackend.expectGET('phones/xyz.json').respond(xyzPhoneData);
|
||||
|
||||
$routeParams['phoneId'] = 'xyz';
|
||||
$routeParams.phoneId = 'xyz';
|
||||
|
||||
ctrl = $componentController('phoneDetail');
|
||||
}));
|
||||
|
|
|
@ -5,7 +5,7 @@ class PhoneDetailController {
|
|||
|
||||
static $inject = ['$routeParams', 'Phone'];
|
||||
constructor($routeParams: angular.route.IRouteParamsService, Phone: any) {
|
||||
let phoneId = $routeParams['phoneId'];
|
||||
let phoneId = $routeParams.phoneId;
|
||||
this.phone = Phone.get({phoneId}, (phone: any) => {
|
||||
this.setImage(phone.images[0]);
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@ class PhoneDetailController {
|
|||
|
||||
static $inject = ['$routeParams', 'phone'];
|
||||
constructor($routeParams: angular.route.IRouteParamsService, phone: Phone) {
|
||||
let phoneId = $routeParams['phoneId'];
|
||||
let phoneId = $routeParams.phoneId;
|
||||
phone.get(phoneId).subscribe(data => {
|
||||
this.phone = data;
|
||||
this.setImage(data.images[0]);
|
||||
|
|
|
@ -42,7 +42,7 @@ describe('PhoneDetailComponent', () => {
|
|||
declarations: [ CheckmarkPipe, PhoneDetailComponent ],
|
||||
providers: [
|
||||
{ provide: Phone, useClass: MockPhone },
|
||||
{ provide: ActivatedRoute, useValue: new ActivatedRouteMock({ params: { 'phoneId': 1 } }) }
|
||||
{ provide: ActivatedRoute, useValue: new ActivatedRouteMock({ params: { phoneId: 1 } }) }
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
|
|
|
@ -22,7 +22,7 @@ export class PhoneDetailComponent {
|
|||
mainImageUrl: string;
|
||||
|
||||
constructor(routeParams: RouteParams, phone: Phone) {
|
||||
phone.get(routeParams['phoneId']).subscribe(phone => {
|
||||
phone.get(routeParams.phoneId).subscribe(phone => {
|
||||
this.phone = phone;
|
||||
this.setImage(phone.images[0]);
|
||||
});
|
||||
|
|
|
@ -42,7 +42,7 @@ describe('PhoneDetailComponent', () => {
|
|||
declarations: [ CheckmarkPipe, PhoneDetailComponent ],
|
||||
providers: [
|
||||
{ provide: Phone, useClass: MockPhone },
|
||||
{ provide: ActivatedRoute, useValue: new ActivatedRouteMock({ params: { 'phoneId': 1 } }) }
|
||||
{ provide: ActivatedRoute, useValue: new ActivatedRouteMock({ params: { phoneId: 1 } }) }
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
|
|
Loading…
Reference in New Issue