0
divをクリックすると、背景が黄色に変わる必要があります。起こっていない、エラーも与えられていない。 Pl、理由を説明してください!クリック時にディレクティブの背景が変更されない(イベントバインディングを介して)
//module declaration
var app = angular.module("myApp",[]);
//controller declaration
app.controller('myCtrl',function($scope){
\t $scope.name = 'Peter';
});
//directive declaration
app.directive('myStudent', function(){
\t return{
\t \t template:"<div style='width:200px;height:200px;'>Hi my friend!</div>",
\t \t link: function(scope, elem, attrs){
\t \t \t elem.bind('click',function(){
\t \t \t \t elem.css("background","yellow");
\t \t \t });
\t \t }
\t }
});
<body ng-app="myApp" ng-controller="myCtrl">
{{name}}<br/>
<my-student></my-student>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.5/angular.min.js"></script>
</body>