When use 'require', recommend to add some error check, for example: class ChildCtrl { constructor(){ // Get prop from parent ctrl if(this.parentCtrl){ this.childProp = this.parentCtrl.prop; } } } app.directive('someDirective', () => { return { requir…
angularjs可交互的directive http://jsfiddle.net/revolunet/s4gm6/ directive开发上手练手,以注释的方式说明 html <body ng-app="demo" ng-controller="demoController"> <h3>rn-stepper demo (1/5){{rating}}</h3> Model value : {{ rating }}<br&g…
原版地址:http://docs.angularjs.org/guide/dev_guide.mvc.understanding_model 在angular文档讨论的上下文中,术语“model”可以适用于单一对象代表一个实体(例如,一个叫” phones”的model,它的值是一个电话数组.)或者作为应用的全部数据Model(所有实体). 在angular中,model可以是任意数据,可以通过angular的scope对象的属性来获取model.属性的名称是model的标识,值可以是任意jav…
原版地址:http://docs.angularjs.org/guide/dev_guide.mvc.understanding_model 在angular中,controller是一个javascript 函数(type/class),被用作扩展除了root scope在外的angular scope(http://www.cnblogs.com/lcllao/archive/2012/09/23/2698651.html)的实例.当我们或者angular通过scope.$new API(h…
本文转自https://www.w3ctech.com/topic/1612 原文作者: Nicolas Bevacqua 原文:AngularJS’ Internals In Depth, Part 2 在这系列的上一篇文章,我讨论了scope事件以及digest循环的行为.这一次,我将谈论指令.这篇文章包括 独立的scope,内嵌,link函数,编译器,指令控制器等等. 如果这个图表看起来非常的费解,那么这篇文章很适合你. (Image credit: Angular JS document…
粗略地翻了一遍<JavaScript DOM编程艺术>,就以为可以接过AngularJS的一招半式,一个星期过去了,我发现自己还是Too Young,Too Simple!(刚打照面的时候,我就被乱棍砸晕了-_-!) 1.AngularJS是何方神圣 Angular JS (Angular.JS) 是一组用来开发Web页面的框架.模板以及数据绑定和丰富UI组件.它支持整个开发进程,提供web应用的架构,无需进行手工DOM操作. AngularJS是为了克服HTML在构建应用上的不足而设计的.H…
之前写过一篇了 http://www.cnblogs.com/keatkeat/p/3903673.html 但某些部分写的不太清楚,甚至有点错误,所以今天特地在这里再来谈谈. 这篇主要是说指令的隔离还有和controller的沟通. 指令的运行过程基本上我们可以简单的理解为 : template -> compile -> controller -> pre-link -> post-link 我们通常只是用到post link,但如果你的指令有嵌套,子层需要父层的一些值的话,可…
先对自定义Directive有一个大体的映像 myModule.directive('myDirective',function(injectables){ var directiveDefinitionObject={ restrict:string, priority:number, template:string, templateUrl:string, replace:bool, transclude:bool, scope:bool or object, controller:func…
<div> <h2>{{vm.userInfo.number}} - {{vm.userInfo.name}}</h2> </div> 'use strict'; class CardTitleInformCtrl { constructor() { } } function CardTitleInformDirective() { return { restrict: 'EA', scope: {}, bindToController: { userInf…
AngularJS 通过被称为 指令 的新属性来扩展 HTML. 正如你所看到的,AngularJS 指令是以 ng 作为前缀的 HTML 属性. HTML5 允许扩展的(自制的)属性,以 data- 开头. AngularJS 属性以 ng- 开头,但是您可以使用 data-ng- 来让网页对 HTML5 有效. 以下列举了一些指令,并不一定常用,但是都有用! 有些指令相关的demo,有兴趣的可以下载,github地址:https://github.com/392468072/demo 自带指…