javascript - does a directive need to list the service? -


i know there few ways format but, if new service injected controller:

analyticscontroller.$inject = ['$scope', 'analyticsservice', 'nvd3', 'gridster']; 

does service still need in directive in angular 1.5?

import { analyticscontroller } './analytics.controller';  export class analyticscomponent {    constructor(){     this.bindings = {       chartdata: '<'     };     this.controller = analyticscontroller;     this.controlleras = 'vm';     this.templateurl = 'analytics/analytics.html'; //maybe service?   } } 

after injecting service use constructor expose class service.

analyticscomponent.$inject = ['$scope', 'analyticsservice', 'nvd3', 'gridster'];  export class analyticscomponent {     constructor($scope, analyticsservice, nvd3, gridster) {         this.bindings = {             chartdata: '<'         };         this.controller = analyticscontroller;         this.controlleras = 'vm';         this.templateurl = 'analytics/analytics.html';         this.analyticsservice = analyticsservice;     }      setanalytics(data) {         this.analyticsservice.methodname(data);     } } 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -