指令隔离作用域 绑定策略

@  指令模板的变量,绑定到dom里的属性的值

= 父级作用域上的属性进行双向绑定, 父级数据模型会发生改变

&  绑定父级作用域上的函数

<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head >
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="angular.js"></script>

</head>
<body>
    <div ng-controller="parentController" >
        <input ng-model="indexx" type="text"  aa="hhh"/>
        <son-dir  dd=indexx  aa="hhh">   //指令的父级  在此可以添加属性与指令内部模板进行传值   若是引用  用 dd ={{index}}  若是双向绑定  则 dd = index
</
son-dir> </div> </body> <script> (function(){ var parentController = function($scope){ $scope.indexx = "dsaf"; } var sonDir = function(){ return{ restrict:"AE", scope:{ dd:"@aa" }, template:"<input ng-model=dd type='text'/><span>{{dd}}</span>" } } angular.module("myApp",[]) .controller("parentController",parentController) .directive("sonDir",sonDir ); })(); </script> </html>
原文地址:https://www.cnblogs.com/RonnieQin/p/9116575.html