angularjs directive 传参数进去不能正常显示

  <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>

然后名字和性别不能正常显示,百思不得其解啊
clipboard.png

阅读 2.4k
1 个回答

ng-controller="testCtrl"写成了controller="testCtrl".

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题