肉饼博客

Talk is cheap. Show me the code.

0%

一、在根模块导入HttpModule

1
2
3
4
import {HttpModule } from "@angular/http";
imports: [
HttpModule
],
阅读全文 »

一、在根模块中引入依赖

1
2
3
4
5
6
import {FormsModule, ReactiveFormsModule } from '@angular/forms';

imports: [
FormsModule,
ReactiveFormsModule
],
阅读全文 »

一、事件绑定

<button (click)= "onButtonClick($event)"></button>

二、DOM属性绑定(插值表达式)

<img [src]="imgUrl">
<img src="">

阅读全文 »

一、概念

名词 解释
Routes 路由配置,保存着哪个URL对应展示哪个组件,以及在哪个RouterOutlet中展示组件
RouterOutlet 在HTML中标记路由内容呈现位置的占位符
Router 负责在运行时执行路由的对象,可以通过调用其navigate()和navigateByUrl()方法来导航到一个指定的路由
RouterLink 在HTML中声明路由导航用的指令
ActivatedRoute 当前激活的路由对象,保存着当前路由的信息,如路由地址、路由参数等
阅读全文 »

一、path传参

1.路由配置(app-routing.module.ts)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import {NgModule} from '@angular/core';
import {Routes, RouterModule} from '@angular/router';
import {AppComponent} from './app.component';
import {LoginComponent} from './login/login.component';
import {UserComponent} from './user/user.component';

const routes: Routes = [
{path: '', component: LoginComponent},
{path: 'login', component: LoginComponent},
{path: 'user/:id', component: UserComponent} //id段传参
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
阅读全文 »

1.下载 Admin LTE,并解压到本地

2.将解压所得的三个文件夹:bower_components、dist、plugins,拷贝至ng目录的src/assets下

更新(2018/05/18):原方法会造成ng serve缓慢,并在build后,在assets文件夹下产生大量文件,不利于部署
1.分别npm install bootstrap/jQuery/adminlte三个依赖包

阅读全文 »