国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
anagularJs指令的controller,link,compile有什么不同

 

/directives.js增加exampleDirective  phonecatDirectives.directive('exampleDirective', function() {      return {          restrict: 'E',          template: '<p>Hello {{number}}!</p>',          controller: function($scope, $element){              $scope.number = $scope.number + "22222 ";          },          link: function(scope, el, attr) {              scope.number = scope.number + "33333 ";          },          compile: function(element, attributes) {              return {                  pre: function preLink(scope, element, attributes) {                      scope.number = scope.number + "44444 ";                  },                  post: function postLink(scope, element, attributes) {                      scope.number = scope.number + "55555 ";                  }              };          }      }  });    //controller.js添加  dtControllers.controller('directive2',['$scope',      function($scope) {          $scope.number = '1111 ';      }  ]);    //html  <body ng-app="phonecatApp">      <div ng-controller="directive2">          <example-directive></example-directive>      </div>  </body>  

運(yùn)行結(jié)果:

 Hello 1111 22222 44444 55555 ! 

由結(jié)果可以看出來,controller先運(yùn)行,compile后運(yùn)行,link不運(yùn)行。

將上例中的compile注釋掉

//        compile: function(element, attributes) {  //            return {  //                pre: function preLink(scope, element, attributes) {  //                    scope.number = scope.number + "44444 ";  //                },  //                post: function postLink(scope, element, attributes) {  //                    scope.number = scope.number + "55555 ";  //                }  //            };  //        }  

運(yùn)行結(jié)果:

Hello 1111 22222 33333 ! 

由結(jié)果可以看出來,controller先運(yùn)行,link后運(yùn)行,link和compile不兼容。

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Adding the "rel" and "title" attributes to im...
Angular開發(fā)中的注意事項(xiàng)
StackOverFlow精彩問答賞析:有jQuery背景的開發(fā)者如何建立起AngularJS的思維模式?
jQuery和AngularJS的區(qū)別淺析
AngularJS 中的一些坑
AngularJS學(xué)習(xí)筆記
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服