本文整理匯總了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) => {