-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Foo.ts
import {inject} from 'ng-injector'
@inject([
'$http'
])
export default class Foo {
constructor(private userId: string) {}
getBirth() {
return this.$http.get(`api.test.com/${this.userId}/age`)
}
}Bar.ts
import {inject} from 'ng-injector'
import Foo from './Foo'
@inject([
'$state'
])
class Bar {
birth: string
private foo: Foo
constructor() {
const userId = this.$state.params._id
// see here
this.foo = new Foo(userId)
}
onInit() {
return this.foo
.getBirth()
.then(birth => this.birth = birth)
}
}
angular.module('App').controller('Bar', Bar)