angular.js injectable module(a custom directive)

علی ذوالفقار
1399/06/23 07:44:51 (673)
angular.js injectable module(a custom directive)

myCustomControl.js  : 

angular.module('myCustomControl', []) .directive('myControl', function(){ //-> my-control return { template : "<'h1>this is my custom control</h1>" } }) ngApp.js :
var app = angular.module('app', ['myCustomControl']); // inject myCustomControl(module name) app.controller("mainCtrl",function($scope){ $scope.title = "title from ngapp.mainCtrl"; }); app.directive('azTest',function(){ // on othe directive but in ngapp return { template : "<h1>a directive in ngapp</h1>" } }); index.html :
<html> <head> <script src="./angular.min.js"></script> <script src="./myCustomControl.js"></script> <script src="./ngapp.js"></script> </head> <body ng-app="app" ng-controller="mainCtrl"> title : {{title}} <az-test></az-test> <my-control></my-control> </body> </html>
Back