<!DOCTYPE html>
<html lang="zh-cn" ng-app="myApp">
<head>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
<meta http-equiv="x-ua-compatible" content="IE=edge">
<meta charset="utf-8">
<title></title>
</head>
<body>
<div ng-controller="listCtrl">
<input type="text" ng-model="t" />
<kid title="{{t}}" > //这个必须指定的,这里的title是指令里scope的@对应的,t就是控制域scope下的
<span>我的angularjs</span>
</kid>
</div>
<script src="js/angular.js"></script>

<script>

var myApp=angular.module('myApp',['ng']);
myApp.controller('listCtrl',function($scope){
$scope.logchore="motorola";
});
myApp.directive('kid',function(){
return {
'restrict':'E',
scope:{
title:"@"
},
template:'<div >{{title}}</div>'

}
});
</script>
</body>
</html>

相关文章:

  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-31
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-28
  • 2022-01-02
  • 2022-01-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案