javascript - Yeoman Angularjs How to Implement Directive -
i'm trying feet off ground yeoman + angular , going through tutorials, can't basic directives fire, when try them same in tutorials.
could please lend insight i'm missing, i've been struggling past 2 days
html template - ng-resize intended directive
<body ng-app="mvmdapp"> .... <div ng-mousemove="onmouse($event)" ng-resize="" class="youtube-cover ng-scope"> <div class="youtube-unit"></div> </div>
// controllers/youtube.js 'use strict'; angular.module('mvmdapp').controller('youtubectrl', function($scope) { console.log('hi');// fires return $scope.onmouse = function(e) {}// fires
// directives/resize.js 'use strict'; angular.module('mvmdapp', []).directive('ngresize', function($window) { return function(scope) { return console.log('directive');// not fire }; });
the strange thing whenever call angular.module('mvmdapp', [])
directive script, blocks view rendering.
edit: noticed when load directive before other scripts, doesn't block html rendering, still doesn't trigger directive. don't know if/how load order of angular scripts matters don't know find that.
this may not solve issue 1 mistake see is
angular.module('mvmdapp', [])
been declared @ multiple places, resize.js , app.js. format declaration creates new module everytime name.
this should called once app.js. in resize.js should angular.module('mvmdapp')
Comments
Post a Comment