Style and View Encapsulation is best understood by seeing how each option (Emulated, Native, and None) compare to each other. <html> <head> <title>Angular 2 QuickStart</title> <style> .started{ background-color: #0b97c4; } .c…
Each time you use the Async Pipe, you create a new subscription to the stream in the template. This can cause undesired behavior especially when network requests are involved. This lesson shows how to use a BehaviorSubject to observe the http stream…
Using the Angular 2 router requires defining routes, passing them in to the RouterModule.forRoot and then importing the configured RouterModule into your main App Module. Use the Wiki Search as example project. Create a HomeComponent to contain every…
Now that Angular 2 is in beta, the time has come for us to drop everything and learn something new, again. The good news is, like React and Angular 1.x, Angular 2 is here to stay for a while so it’s a good investment to become productive with this ne…
 只记录一些自己未曾用过,但觉得对以后的项目有帮助的规范 一 Javascript闭包 把Angular组件包装到一个立即调用函数表达式中(IIFE). 为什么?:把变量从全局作用域中删除了,这有助于防止变量和函数声明比预期在全局作用域中有更长的生命周期,也有助于避免变量冲突. 为什么?:当你的代码为了发布而压缩了并且被合并到同一个文件中时,可能会有很多变量发生冲突,使用了IIFE(给每个文件提供了一个独立的作用域),你就不用担心这个了. /* avoid */ // logger.js ang…
声明 本系列文章内容梳理自以下来源: Angular 官方中文版教程 官方的教程,其实已经很详细且易懂,这里再次梳理的目的在于复习和巩固相关知识点,刚开始接触学习 Angular 的还是建议以官网为主. 因为这系列文章,更多的会带有我个人的一些理解和解读,由于目前我也才刚开始接触 Angular 不久,在该阶段的一些理解并不一定是正确的,担心会有所误导,所以还是以官网为主. 正文- Angular-CLI 命令 Angular 的项目其实相比老旧的前端项目模式或者是 Vue 的项目来说,都会比较…
import { Injectable } from '@angular/core'; import { ProductServiceService, Product } from './product-service.service'; @Injectable() export class AnotherProductServiceService implements ProductServiceService { getProduct(): Product { , "sunsung7&quo…
import { Injectable } from '@angular/core'; @Injectable() export class ProductServiceService { constructor() { } getProduct(): Product { , "iPhone7"); } } export class Product { constructor( public id: number, public title: string ) { } } import…
引入样式: 导入全局 - >styles.css 导入第三方 - > 在package.json配置,然后再 npm install 安装好以后,最后再angular.json里面的styles添加node_module安装的第三方包 app里面的src目录都是模板: app.component.css 是模板样式 app.component.html是模板 app.component.ts 是配置 app.module.ts 是模块 package.json : 包管理依赖 REMALE.m…
目录: 1.安装  angular cli 2.创建项目 3.构建路由 4.新建组件 5.组件之间的通信 6.引入primeNG 7.修改primeNG组件样式 8.问题 ------------------------------------------------------------------------------------------ 1.安装  angular cli 命令 --cnpm install -g @angular/cli 安装完成后可以查看版本是否ok --ng…