An AngularJS directive for NVD3 re-usable charting library (based on D3).
Easily customize your charts via JSON API.
NVD3讓你可以透過directive來實現D3的繪圖效果: D,使用Angular需要圖表呈現可以考慮
app.directive('errSrc', function() { return { link: function(scope, element, attrs) { scope.$watch(function() { return attrs['ngSrc']; }, function (value) { if (!value) { element.attr('src', attrs.errSrc); } }); element.bind('error', function() { element.attr('src', attrs.errSrc); }); } } })
app.config()
app.run()
app.controller()
Run blocks - get executed after the injector is created and are used to kickstart the application. Only instances and constants can be injected into run blocks. This is to prevent further system configuration during application run time.Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests.
<div ng-app="myApp" ng-controller="myCtrl"> <div test1 test2> </div> </div>
var myApp = angular.module('myApp', []); myApp.factory('aProvider', function() { console.log("factory"); }); myApp.directive("test1", function() { console.log("directive setup"); return { compile: function() {console.log("directive compile");} } }); myApp.directive("test2", function() { return { link: function() {console.log("directive link");} } }); myApp.run(function() { console.log("app run"); }); myApp.config( function() { console.log("app config"); }); myApp.controller('myCtrl', function($scope) { console.log("app controller"); });