Answer the question
In order to leave comments, you need to log in
How to "use" Angular 2?
So I decided to try new technologies for a day. I installed angular2-webpack-starter and turned it on in a stupor.
I want to make a table component with pagination. For it, I will need (well, as I understand it) to declare a component, have a service (for the logic of issuing a page with pagination) and a directive for pagination buttons. Made a table folder, made a file:
import {Component} from 'angular2/core';
interface TableInterface {
id: number;
name: string;
}
@Component({
selector: 'med-table',
template:`
<h1>Table</h1>
<table>'
<tbody>
<tr *ngFor="#table of data">
<td {{table.name}}></td>
</tr>
<tbody>
</table>`,
styles:[` `]
})
export class Table {
public data = DATA;
constructor() {
}
}
// Добавил из Heroes Tour
var DATA: TableInterface[] = [
{ "id": 11, "name": "Mr. Nice" },
{ "id": 12, "name": "Narco" },
{ "id": 13, "name": "Bombasto" },
{ "id": 14, "name": "Celeritas" },
{ "id": 15, "name": "Magneta" },
{ "id": 16, "name": "RubberMan" },
{ "id": 17, "name": "Dynama" },
{ "id": 18, "name": "Dr IQ" },
{ "id": 19, "name": "Magma" },
{ "id": 20, "name": "Tornado" }
];
import {Table} from '../components/table/table';
<med-table></med-table>
Answer the question
In order to leave comments, you need to log in
Everything is described in the docs.
https://angular.io/docs/ts/latest/quickstart.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question