I'm working on a relatively small web portal running on top of Angular. I'm still an Angular greenhorn, though I've managed to wrap my mind around the more important concepts.
In any event, I was creating a small widget/plugin for GitHub data retrieval. This is my code,
ng-github.js
(function() {
angular.module('ng-github', [])
.run(function() {
console.log('module instantiated');
})
.directive('git-user', function($http) {
return function(scope, element, attr) {
console.log('invoked');
$http.get('https://api.github.com/users/' + attr['gitUser'])
.success(function(data) {
scope.gUser = data;
})
.error(function(data, status) {
console.error('Github User Request Error', status, data);
})
};
})
})();
view.html
...
<span gitUser="neetVeritas" ng-bind="gUser.following"></span>
...
The module is being instantiated, as I'm getting a response from the .run(...) function, but the directive's link function is not being invoked. I've included the ng-github module in my main application, and I'm not receiving any angular-js related errors, so I'm stumped here. Any ideas?
module(...).directive('gitUser', ...)and use it as<span git-user="...">. I.e.: directive definition in code: camelCase, directive usage in HTML: dash-case.