Here issue is how to set the input model value from a service in Angular 2.
Here is my sample code:
component:
//our root app component
import {Component} from 'angular2/core'
import {Service} from './service'
@Component({
selector: 'my-directive',
providers: [],
template: `<input [(ngModel)]="abc">`,
directives: []
})
export class Directive {
constructor(public service: Service) {
this.abc = this.service.value;
}
}
service:
//our root app component import {Injectable} from 'angular2/core'
@Injectable()
export class Service {
constructor() {
this.value = "service"
}
abcFun(){
// need to update value from here
}
}
_abcServicereturning what you want to store insidethis.modal?