當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Provide.provider方法代碼示例

本文整理匯總了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()
        })
開發者ID:trotyl,項目名稱:typed-angular,代碼行數:15,代碼來源:provide.spec.ts

示例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) => {
開發者ID:trotyl,項目名稱:typed-angular,代碼行數:16,代碼來源:provide.spec.ts


注:本文中的angular.Provide.provider方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。