javascript - Creating Custom directive do not work -


i trying create custom directive..

 <head>     <script type="text/javascript" src="../scripts/angular.min.js"></script>     <script type="text/javascript" src="../scripts/datadirectives.js"></script>     </head>     <body  style="overflow: hidden" >       <div ng-app="myapp">         <sampledata></sampledata>       </div>     </body> 

in separate javascript file called datadirectives.js followung code present..

var app = angular.module('myapp', []);  app.directive('sampledata', function () {     return {         restrict: 'e',         template: '<div>sample div,to test angular directives</div>'     }; }); 

so when run page,i cannot see text on page of of div element.what wrong above code. in advance... :)

you have 2 ng-app not following required naming convensions

var app = angular.module('myapp', []);    app.directive('sampledata', function() {    return {      restrict: 'e',      template: '<div>sample div,to test angular directives</div>'    };  });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>  <div ng-app="myapp">    <sample-data></sample-data>  </div>


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -