本文整理汇总了TypeScript中ng-metadata/core.provide函数的典型用法代码示例。如果您正苦于以下问题:TypeScript provide函数的具体用法?TypeScript provide怎么用?TypeScript provide使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了provide函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
import '../../node_modules/angular-material/angular-material.scss'
import './app.scss';
import * as angular from 'angular';
// import * as ngAria from 'angular-aria';
// import * as ngMessages from 'angular-messages';
import * as ngSanitize from 'angular-sanitize';
import * as ngMaterial from 'angular-material';
import '../assets/svg-assets.js';
import { provide } from 'ng-metadata/core';
import { AppComponent } from './app.component.ts';
import { Configure } from './app.config';
const ngMaterialSvg = 'material.svgAssetsCache';
export const AppModule = angular.module( 'app', [
ngSanitize,
// ngAria,
ngMaterial,
ngMaterialSvg
] )
.config( Configure )
.directive( ...provide( AppComponent ) );
示例2:
import * as angular from "angular"; // import angular globally
import { provide } from "ng-metadata/core";
import { AppCmp } from "./components/my-app.component";
// return/export the module so you can later bootsrap it in the startup using ngMetadata
// define 'app' module and register all components and services defined in other files imported above...
export const AppModule = angular.module( "app", [] )
.directive( ...provide( AppCmp ) )
.name
;
示例3:
// import * as angular from "angular"; // deccoment to include in the bundle and define angular globally
import { provide } from "ng-metadata/core";
import { AppCmp } from "./components/my-app.component";
import { AskCmp } from "./components/ask.component";
import { QuestionSvc } from "./services/question.service";
import myapp from "../myapp"
// return/export the module so you can later bootsrap it in the startup using ngMetadata
// define 'app' module and register all components and services defined in other files imported above...
export const AppModule = angular.module( "app", [ myapp ] )
.directive( ...provide( AppCmp ) )
.directive( ...provide( AskCmp ) )
.service( ...provide( QuestionSvc ) )
.name
;
示例4:
import * as angular from 'angular';
import { provide } from 'ng-metadata/core';
import {
MarkForCheckComponent,
DetachComponent,
DataProvider,
ChangeDetectorComponent,
DataProvider2,
ReattachComponent
} from './change-detector.component';
export const ChangeDetectorModule = angular
.module( 'changeDetector', [] )
.directive(...provide(ChangeDetectorComponent))
.directive(...provide(MarkForCheckComponent))
.directive(...provide(DetachComponent))
.directive(...provide(ReattachComponent))
.service(...provide(DataProvider))
.service(...provide(DataProvider2))
.name;
示例5:
// import * as ngMessages from 'angular-messages';
import * as ngSanitize from 'angular-sanitize';
import * as ngMaterial from 'angular-material';
import '../assets/svg-assets.js';
import { provide } from 'ng-metadata/core';
import { AppComponent } from './app.component.ts';
import { Configure } from './app.config';
import { AppService } from './app.service';
import { MapComponent } from './components/map/map.component';
import { MapHandlerDirective } from './components/map/map-handler.directive';
import { ProgramComponent } from './components/program/progam.component';
import { SpeakersComponent } from './components/speakers/speakers.component';
const ngMaterialSvg = 'material.svgAssetsCache';
export const AppModule = angular.module( 'app', [
ngSanitize,
// ngAria,
ngMaterial,
ngMaterialSvg
] )
.config( Configure )
.service( ...provide( AppService ) )
.directive( ...provide( AppComponent ) )
.directive( ...provide( MapComponent ) )
.directive( ...provide( MapHandlerDirective ) )
.directive( ...provide( ProgramComponent ) )
.directive( ...provide( SpeakersComponent ) )
;
示例6:
import * as ngAnimate from 'angular-animate';
import { provide } from 'ng-metadata/core';
import { CoreModule } from '../core/core.module';
import { PhoneDetailComponent } from './phone-detail.component';
import { phoneAnimation } from './phone.animation';
export const PhoneDetailModule = angular
.module( 'phonecat.phoneDetail', [
ngAnimate,
CoreModule
] )
.directive( ...provide( PhoneDetailComponent ) )
.animation( '.phone', phoneAnimation )
.name;
示例7: constructor
export class SomeClassToInstantiate{
constructor(private $timeout:ng.ITimeoutService, private $log:ng.ILogService){}
greetWithDelay(){ this.$timeout(()=>console.info('greetings from SomeClassToInstantiate with delay!'),1000)}
}
// this is just showcase how to define config for your app or if you are building 3rd party module
configureProviders.$inject = [ '$provide' ];
export function configureProviders( $provide ) {
$provide.service( ...provide(NgRxStore, {useClass: NgRxStore}) )
$provide.value( ...provide(DynamicValueToken, {useValue:'hello'}) );
$provide.factory(...provide(SomeFactoryFnToken, { deps: ['$timeout', '$log'], useFactory: ($timeout, $log) => () => new SomeClassToInstantiate($timeout, $log) }));
}
export const Ng1LegacyModule = angular.module( 'LegacyNg1Module', [
TabsModule,
LifecycleHooksModule,
ChangeDetectorModule,
TitleHandlerModule
] )
.directive( ...provide( ElementReadyDirective ) )
.directive( ...provide( MyValidatorDirective ) )
.directive( ...provide( MyFooDirective ) )
.directive( ...provide( MyFormBridgeDirective ) )
.directive( ...provide( MyDirectiveTesterDirective ) )
.directive( ...provide( TesterComponent ) )
.directive( ...provide( GlobalListenerDirective ) )
.directive( ...provide( TesterAttrDirective ) )
.name;
示例8: configureProviders
export function configureProviders( $provide ) {
$provide.service( ...provide(NgRxStore, {useClass: NgRxStore}) )
$provide.value( ...provide(DynamicValueToken, {useValue:'hello'}) );
$provide.factory(...provide(SomeFactoryFnToken, { deps: ['$timeout', '$log'], useFactory: ($timeout, $log) => () => new SomeClassToInstantiate($timeout, $log) }));
}
示例9:
import { MyValidatorDirective } from './directives/my-validator.directive';
import { MyFooDirective } from './directives/my-foo.directive';
import { MyFormBridgeDirective } from './directives/my-form-bridge.directive';
import { MyDirectiveTesterDirective } from './directives/my-directive-tester.directive';
import { TesterAttrDirective } from './directives/my-tester.directive';
import { GlobalListenerDirective } from './directives/global-listener.directive';
import { TesterComponent } from './components/tester/tester.component';
export const AppModule = angular.module( 'app', [
TabsModule,
LifecycleHooksModule,
ChangeDetectorModule,
TitleHandlerModule
] )
// we need to register the service manually
.service( ...provide( Title ) )
.directive( ...provide( TodoAppCmp ) )
.directive( ...provide( AddTodoCmp ) )
.directive( ...provide( TodoItemCmp ) )
.filter( ...provide( RemainingTodosPipe ) )
.service( ...provide( TodoStore ) )
.directive( ...provide( ElementReadyDirective ) )
.directive( ...provide( MyValidatorDirective ) )
.directive( ...provide( MyFooDirective ) )
.directive( ...provide( MyFormBridgeDirective ) )
.directive( ...provide( MyDirectiveTesterDirective ) )
.directive( ...provide( TesterComponent ) )
.directive( ...provide( GlobalListenerDirective ) )