<body ng-app="app" controller="testCtrl">
this is a test
<p test info="harry"></p>
</body>
<script>
var App = angular.module('app',[])
App.directive('test', function(){
return {
restrict: "A",
scope:{
info: "="
},
template: "<p>name{{info.name}}</p><p>sex{{info.sex}}</p>"
};
});
App.controller('testCtrl', function($scope){
$scope.harry = {
name: "vincent",
sex: "男"
}
});
</script>
然后名字和性别不能正常显示,百思不得其解啊
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
ng-controller="testCtrl"写成了controller="testCtrl".