AngularJs Adding methods to controller from a component -


i want 2 different components share same controller. want add method each component , have method available when component being used.

i'm trying this.

app.component('mycomponent',{   templateurl: 'mytemplate.html',   controller: 'mycontroller', ['myservice', function(myservice){     //extra things here     }] }); 

then second component similar, else inside controller method.

i know doesn't work, there way make work? or better way make work.

thank in advance.

try use $broadcast subscription take here https://toddmotto.com/all-about-angulars-emit-broadcast-on-publish-subscribing/


Comments