<!DOCTYPE html> <html ng-app="MyModule"> <head> <link rel="stylesheet" href="bootstrap.min.css" /> <script src="jquery.js"></script> <script src="angular.min.js"></script> <script src="bootstrap.min.js"></script> <!--<script src="angular-bootstrap-checkbox.js"></script>--> <!--<script src="app.js"></script>--> </head> <body> <div ng-controller="myController"> <div class="result"> <div>父scope: <div>Say:{{name}}<br>改变父scope的name:<input type="text" value="" ng-model="name"/></div> </div> <div>隔离scope: <div isolated-directive name="{{name}}"></div> </div> <div>隔离scope(不使用{{name}}): <div isolated-directive name="name"></div> </div> </div> </body> <script type="text/javascript"> var app = angular.module("MyModule", []); app.controller("myController", function ($scope) { $scope.name = "hello world"; }).directive("isolatedDirective", function () { return { scope: { name: "@" }, template: 'Say:{{name}} <br>改变隔离scope的name:<input type="buttom" value="" ng-model="name" class="ng-pristine ng-valid">' } }) </script> </html>
angularjs的自定义指令的 @ 局部 scope 属性
最新推荐文章于 2020-04-28 18:41:41 发布