<body ng-app="app" controller="testCtrl">
this is a test
<div test info="harry"></div>
</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>
然后名字和性别不能正常显示,百思不得其解啊
ng-controller="testCtrl"写成了controller="testCtrl".