angular.js学习(1)--directive指令独立scope
2016-10-05 16:09
756 查看
1、@
<div ng-controller="love"> <drink myfaver={{fover}}></drink> </div>
ar app = angular.module("app",[]); app.controller("love",["$scope",function($scope){ $scope.fover="百事可乐"; }]) .directive("drink",function(){ return{ restrict:"AE", scope:{ myfaver:'@' }, template:"<div>{{myfaver}}</div>" } })
2、=
var app=angular.module("app",[]); app.controller("love",["$scope",function($scope){ $scope.fover="百事可乐"; }]) .directive("drink",function(){ return{ restrict:"AE", scope:{ myfaver:'=' }, template:"<input type='text' ng-model='myfaver'/>" } })
<div ng-controller="love"> 控制器: <input type="text" ng-model="fover" /> 指令: <drink myfaver="fover"></drink> </div>
3、&
var app=angular.module("app",[]); app.controller("myinput",["$scope",function($scope){ $scope.getName = function(myname){ alert(myname); } }]) .directive("setinput",function(){ return{ restrict:"AE", scope:{ greet:"&" }, template:"<div><input type='text' ng-model='name' /><button class='btn btn-primary' ng-click='greet({myname:name})'>得到名字</button></div>" } })
<div ng-controller="myinput"> <setinput greet="getName(myname)"></setinput> </div>
相关文章推荐
- angularjs directive 指令 学习笔记
- Angularjs Directive(指令)机制
- AngularJS clone directive 指令复制
- angularjs directive 获取scope内容不正确的问题。
- angular.js学习(1)--指令和控制器间的交互
- angular学习笔记(三十)-指令(8)-scope
- AngularJS Directive 隔离 Scope 数据交互
- AngularJS Directive 隔离Scope数据交互
- AngularJS Directive 隔离 Scope 数据交互
- angular.js学习(1)--指令执行机制
- Angularjs+ionic 学习(一):Angularjs常用指令
- AngularJs directive-scope双向绑定方法处理-实例2
- AngularJS directive指令之require部分
- AngularJS Directive 隔离 Scope 数据交互
- AngularJS clone directive 指令复制
- AngularJS directive 实现分页包装指令
- AngularJs directive指令实例
- AngularJs directive-scope
- AngularJS Directive 隔离 Scope 数据交互
- AngularJS Directive 隔离 Scope 数据交互