=========== html

<div *nfIf="articles">

<ul>

<li *nfFor="let article of articles">

<a href="#">{{article.title}}</a></li>

</ul>

</div>


=========== ts

import {Compontnt} from '@angular/core';

import {Http} from '@angular/http';


interface IArticles{

id : number;

title : string;

}

@Component({

selector:'webcamp'

template : requier('./exam.component.html')

})

export class WebCampComponent{

private API: string = "http://localhost:8080/testService";

public title:string = "TEST";

/*

public articles: any[] = [

{"id":1, title:"test"}

{"id":2, title:"test"}

]

*/

public articles: IArticles[];

constructor(private _http:HTTP){

_http.get(this.API).subscribe(result => {

this.articles = result.json();

});

}

}


=========== ngModule.ts

import {FormsModule} from "@angular/forms"

import {WebCampComponent} from './components/webcamp/webcamp.component'


@NgModule({

declarations :[

WebCampComponent,

],

imports :[

FormsModule,

RouterModule.forRoot([

path : 'webcamp', component:WebCampComponent},

])

]

})


=========== LeftMenu.html

<li [routerLinkActive]="['link-active']"

<a [routeLinnk] = "['/webcamp']">WebCamp</a>

</li>


'angular' 카테고리의 다른 글

sample  (0) 2017.06.28
visual studio code angular intellisense  (0) 2017.06.25
ngModel 과 양방향 바인딩  (0) 2017.02.25
데이타 바인딩  (0) 2017.02.25
데이타 입출력  (0) 2017.02.25

+ Recent posts