AngularJS實現(xiàn)自定義指令與控制器數(shù)據(jù)交互的方法示例
更新時間:2017年06月19日 10:51:50 作者:一花一世界,一葉一乾坤
這篇文章主要介紹了AngularJS實現(xiàn)自定義指令與控制器數(shù)據(jù)交互的方法,結(jié)合具體實例形式分析了AngularJS自定義指令的實現(xiàn)以及與控制器數(shù)據(jù)交互的操作技巧,需要的朋友可以參考下
本文實例講述了AngularJS實現(xiàn)自定義指令與控制器數(shù)據(jù)交互的方法。分享給大家供大家參考,具體如下:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>AngularJS自定義指令與控制器數(shù)據(jù)交互</title> <!-- <script src="http://cdn.bootcss.com/angular.js/1.3.15/angular.js"></script>--> <script src="../../lib/angular/angular.js"></script> <script> angular.module('yyApp', []) .controller('yyHelloController', function($scope){ $scope.data = { name: '張三' } }) .controller('yyHelloController2', function($scope){ $scope.data = { name: '李四' } }) .directive('yyHello', function(){ return{ restrict: 'AE', replace: true, template: '<div name="{{data.name}}">你好,{{data.name}}</div>' }; }); </script> </head> <body ng-app='yyApp'> <yy-hello ng-controller='yyHelloController'></yy-hello> <div ng-controller='yyHelloController2'> <input type="text" ng-model='data.name'> <yy-hello></yy-hello> </div> </body> </html>
更多關(guān)于AngularJS相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《AngularJS指令操作技巧總結(jié)》、《AngularJS入門與進階教程》及《AngularJS MVC架構(gòu)總結(jié)》
希望本文所述對大家AngularJS程序設(shè)計有所幫助。
相關(guān)文章
Angular.js前臺傳list數(shù)組由后臺spring MVC接收數(shù)組示例代碼
這篇文章主要給大家介紹了關(guān)于Angular.js前臺傳list數(shù)組之后,由后臺spring MVC接收數(shù)組的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家具有一定的參考學(xué)習(xí)價值,需要的朋友們下面跟著小編來一起學(xué)習(xí)學(xué)習(xí)吧。2017-07-07anime.js 實現(xiàn)帶有描邊動畫效果的復(fù)選框(推薦)
anime.js是一個靈活的輕型JavaScript動畫庫。這篇文章主要介紹了anime.js 實現(xiàn)帶有描邊動畫效果的復(fù)選框 ,需要的朋友可以參考下2017-12-12