本文整理汇总了TypeScript中angular.Provide.provider方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Provide.provider方法的具体用法?TypeScript Provide.provider怎么用?TypeScript Provide.provider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular.Provide
的用法示例。
在下文中一共展示了Provide.provider方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: done
module.config(($provide: Provide) => {
$provide.provider('customService0', { $get: () => 0 })
$provide.provider('customService1', MyProviderFn)
$provide.provider('customService2', MyProviderClass)
$provide.provider('customService3', ['$controllerProvider', MyProviderFn])
$provide.provider('customService4', ['$controllerProvider', MyProviderClass])
$provide.provider<number, Provider<number>>('customService0', { $get: () => 0 })
$provide.provider<number>('customService1', MyProviderFn)
$provide.provider<number, MyProviderClass>('customService2', MyProviderClass)
$provide.provider<number>('customService3', ['$controllerProvider', MyProviderFn])
$provide.provider<number, MyProviderClass>('customService4', ['$controllerProvider', MyProviderClass])
done()
})
示例2:
module.config(($provide: Provide) => {
// Should have type of Provider<number>
const provider0 = $provide.provider('customService0', { $get: () => 0 })
// Should have type of Provider<any>
const provider1 = $provide.provider('customService1', MyProviderFn)
// Should have type of MyProviderClass
const provider2 = $provide.provider('customService2', MyProviderClass)
// Should have type of Provider<any>
const provider3 = $provide.provider('customService3', ['$controllerProvider', MyProviderFn])
// Should have type of MyProviderClass
const provider4 = $provide.provider('customService4', ['$controllerProvider', MyProviderClass])
}).run((customService0, customService1, customService2, customService3, customService4) => {