Controller in External file inside angularjs directive -


i have problem. have controller:

app.controller("controllerlots", ["$scope", "factoryclient", "factorylots", "factorycontracts", "fillticketfactory", function ($scope, factoryclient, factorylots, factorycontracts, fillticketfactory) {     var vm1 = this;     vm1.lot = {};     vm1.lots = [];     vm1.client = {};     vm1.ticket = {};     vm1.clientfinddb = [];     // vm1.filtername =vm1.client.clientname +""+vm1.client.clientfn+"" +vm1.client.clientpatroncyr;     // vm1.filterpassport = vm1.client.clientserialpass + vm1.client.clientnumberpass;        vm1.selectclient =function(client){         vm1.client=client;         vm1.filtername = vm1.client.clientname +''+vm1.client.clientfn +''+vm1.client.clientpatroncyr;         vm1.filterpassport = vm1.client.clientserialpass +""+vm1.client.clientnumberpass;     }      vm1.addlot = function () {         if (angular.isundefined(vm1.lot.ordernumberlot) || vm1.lot.n <= 0) {             vm1.lots.push(vm1.lot);             vm1.lot.n = vm1.lots.length;         }         vm1.lot = {};     } 

and have directive in want put functions above controller, directive looks like:

app.directive("searchdir", [function(){     return{         scope:{             filtername: '=',             filterpass:'='         },         templateurl:'searchdirective.html',         replace:true,         controlleras:'ctrl',         controller:controller     }  }]); 

how can use functions inside directive? thanks.

how can use functions inside directive?

i guess asking how can use functions in directive template. need add properties, want access in template, "scope".

  1. in directive change controller property of directive like:

    controller: 'controllerlots'

  2. and in controller, instead of adding properties "this", add properties "$scope".


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -