Showing you how you can expose properties on your Controller to access them using #refs inside of your template. // letterSelect.ts import {Component, View, FORM_DIRECTIVES, NgFor} from 'angular2/angular2'; @Component({ selector: 'letter-select' }) @…
Angular 1.5 introduced the .component() helper method, which is much simpler than the.directive() definition and advocates best practices and common default behaviours. Using .component() will allow developers to write in an Angular 2 style as well,…
The main idea for testing contianer component is to make sure it setup everythings correctlly. Call the onInit() lifecycle first, then the variables have the right value. Methods will be called with the right params. Container component: import { Com…
1. 组件Component示例 2. Component常用的几个选项 3. Component全部的选项 3.1 继承自@Directive装饰器的选项 3.2 @Component自己特有的选项 4. 自定义component 1. 组件Component示例 组件是由一个装饰器@Component来声明的,继承自@Directive import {Component} from '@angular/core'; @Component({ selector: 'app-root233',…
Angualr 1.4: .directive('counter', function counter() { return { scope: {}, restrict: 'EA', transclude: true, bindToController: { count: '=' }, controller: function () { function increment() { this.count++; } function decrement() { this.count--; } th…
String Template(字符串模板)在很多编程语言和框架中都支持,是一个很有用的特性.本文将Jerry工作中使用到的String Template的特性做一个总结. ES6 阮一峰老师有一个专门的网站介绍ES6入门,还出了一本书: <ECMAScript6标准入门>. http://es6.ruanyifeng.com/ 我们来看看ES6里的String Template. 首先看下面这段代码. <html> <div id="JerryTest"…
报错现象: 用modal打开某个组件页面时报错 报错:No component factory found for UpdateAuthWindowComponent. Did you add it to @NgModule.entryComponents? 原因: 使用loadChild模式加载对应路由下的组件时,是懒加载模式,即需要的时候才会加载,所以如果路由走的是懒加载模式,需要的module即使在app.module中引入过了,依旧需要再引入一次 解决方案: 在app.module 的e…
Oingial aritial --> Link Take away: import { Component, OnInit } from '@angular/core'; @Component({ selector : 'contacts-header', templateUrl: './header.component.html', styleUrls : ['./header.component.css'] }) export class HeaderComponent implement…
The way to test router componet needs a little bit setup, first we need to create a "router-stubs.ts". This file is a helper file. // export for convenience. export { ActivatedRoute, Router, RouterLink, RouterOutlet} from '@angular/router'; impo…