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


TypeScript angular2.provide函數代碼示例

本文整理匯總了TypeScript中angular2/angular2.provide函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript provide函數的具體用法?TypeScript provide怎麽用?TypeScript provide使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了provide函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: beforeEachProviders

 beforeEachProviders(() => [
   RouteRegistry,
   DirectiveResolver,
   provide(Location, {useClass: SpyLocation}),
   provide(ROUTER_PRIMARY_COMPONENT, {useValue: AppCmp}),
   provide(Router, {useClass: RootRouter})
 ]);
開發者ID:kleitz,項目名稱:angular2-seed,代碼行數:7,代碼來源:app_spec.ts

示例2: beforeEachProviders

 beforeEachProviders(() => [
   RouteRegistry,
   DirectiveResolver,
   provide(Location, {useClass: SpyLocation}),
   provide(Router,
     {
       useFactory:
         (registry, location) => { return new RootRouter(registry, location, App); },
       deps: [RouteRegistry, Location]
     })
 ]);
開發者ID:A-Kamaee,項目名稱:ng2-bootstrap-sbadmin,代碼行數:11,代碼來源:app_spec.ts

示例3: beforeEach

  beforeEach(() => {
    injector = Injector.resolveAndCreate([
      HTTP_BINDINGS,
      MockBackend,
      BaseResponseOptions,
      provide(Http, {
        useFactory: (backend, baseResponseOptions) => {
          return new Http(backend, baseResponseOptions);
        },
        deps: [MockBackend, BaseResponseOptions]
      }),
      TickerLoader
    ]);
    backend = injector.get(MockBackend);
    baseResponseOptions = injector.get(BaseResponseOptions);
    http = injector.get(Http);
    tickerLoader = injector.get(TickerLoader);

    backend.connections.subscribe((c:MockConnection) => {
      var symbol:string[] =/.*stocks\?symbol=(.*)/.exec(c.request.url);
      switch(symbol[1]) {
        case 'a':
          c.mockRespond(new Response(baseResponseOptions.merge({
            body: [{
              "company_name":"Agilent Technologies, Inc. Common Stock","symbol":"A"
            }]
          })))
          break;
        default:
          connection = c;
      }
    });
  });
開發者ID:LongLiveCHIEF,項目名稱:aim,代碼行數:33,代碼來源:ticker_loader_test.ts

示例4: provide

 *   });
 *
 * http.get('people.json').observer({
 *   next: res => {
 *     // Response came from mock backend
 *     console.log('first person', res.json()[0].name);
 *   }
 * });
 * ```
 */
export const HTTP_PROVIDERS: any[] = [
  // TODO(pascal): use factory type annotations once supported in DI
  // issue: https://github.com/angular/angular/issues/3183
  provide(Http,
          {
            useFactory: (xhrBackend, requestOptions) => new Http(xhrBackend, requestOptions),
            deps: [XHRBackend, RequestOptions]
          }),
  BrowserXhr,
  provide(RequestOptions, {useClass: BaseRequestOptions}),
  provide(ResponseOptions, {useClass: BaseResponseOptions}),
  XHRBackend
];

/**
 * @deprecated
 */
export const HTTP_BINDINGS = HTTP_PROVIDERS;

/**
 * Provides a basic set of providers to use the {@link Jsonp} service in any application.
開發者ID:MingXingTeam,項目名稱:awesome-front-end,代碼行數:31,代碼來源:http.ts

示例5: bootstrap

@Component({
    selector: 'router-app',
    template: `
           <h1>Welcome to router example</h1>
           <a [router-link]="['Home']">Home</a>
           <a [router-link]="['ProductDetail', {id: 1234}]">Product Details</a>
           <router-outlet></router-outlet>`,
    directives: [ROUTER_DIRECTIVES]})

/*
 - The path property has an additional fragment /:id.
 The name of this URL fragment must match the name of the parameter property
 used in router-link. Angular will construct the URL fragment /product/1234
 for this ProductDetail route.
 - Angular also offers a mechanism to pass additional data to components at
 the time of the route configuration. For example, besides the data that
 a component needs for implementing application logic, we may need to pass
 a flag indicating if the application runs in production environment or not.
 This can be done by using the data property of the @RouteConfig annotation.
 */
@RouteConfig([
    {path: '/',            component: HomeComponent, as: 'Home'},
    {path: '/product/:id', component: ProductDetailComponent, as: 'ProductDetail'
        , data: {isProd: true}}
])

export class RouterExampleRootComponent{
}

bootstrap(RouterExampleRootComponent, [ROUTER_PROVIDERS, provide(LocationStrategy, {useClass: HashLocationStrategy})]);
開發者ID:israa-ia1205702,項目名稱:Examples,代碼行數:30,代碼來源:router-example.ts

示例6: Route

import { Home } from '/build/scripts/directives/home.js';

@Component({
    selector: 'app'
})

@RouteConfig([
    new Route({ path: '/', component: Landing, as: 'Landing' }),
    new Route({ path: '/home', component: Home, as: 'Home' })
])

@View({
    templateUrl: './templates/parent.html',
    directives: [Landing, Home, ROUTER_DIRECTIVES, CORE_DIRECTIVES]
})

class App {

    router: Router;
    location: Location;
    name: string;

    constructor(router: Router, location: Location) {
        this.router = router;
        this.location = location;
        this.name = 'SALEH KADDOURA';
    }
}

bootstrap(App, [ROUTER_PROVIDERS, HTTP_PROVIDERS, provide(LocationStrategy, { useClass: HashLocationStrategy })]);
開發者ID:kleitz,項目名稱:cmc-angular2,代碼行數:30,代碼來源:app.ts

示例7: Route

import Home from "./home/home";
import Admin from "./admin/admin";

@RouteConfig([
    new Route({path: '/', component: Home, as: 'Home'}),
    new Route({path: '/admin/:user', component: Admin, as: 'Admin', params: {user: "John"}})
])
@Component({
    selector: "app",
    directives: [RouterOutlet, RouterLink],
    template: `
        <nav>
            <a [router-link]="['/Home']">Home</a>
            <a [router-link]="['/Admin', {'user':'John'}]">Admin</a>
        </nav>
        <main>
            <router-outlet></router-outlet>
        </main>
    `
})
class App {
}

bootstrap(App, [
    ROUTER_PROVIDERS,
    provide(LocationStrategy, {useClass: HashLocationStrategy})
])
    .then(
        success => console.log(`app started...`),
        error => console.log(error)
    );
開發者ID:Cod1ngNinja,項目名稱:egghead-angular2-london-workshop-master,代碼行數:31,代碼來源:main.ts

示例8: bootstrap

import {Component, bootstrap, provide} from "angular2/angular2";
import MyAwesomeComponent from "./myAwesomeComponent"
import people from "./people";

@Component({
    selector: 'app',
    directives: [MyAwesomeComponent],
    template: `
        <h1></h1>
        <my-awesome-component></my-awesome-component>
    `
})
class App {
}

bootstrap(App, [
    provide('people', {useValue: people})
]).then(
    success => console.log("app starting..."),
    error => console.log(error)
);
開發者ID:Cod1ngNinja,項目名稱:egghead-angular2-london-workshop-master,代碼行數:21,代碼來源:main.ts

示例9: constructor

import { TravelService } from './travel-service'
import { TravelList } from './travel-list'
import { TravelEdit } from './travel-edit'


@RouteConfig([
    { path: '/',            component: TravelList, as: 'List' },
    { path: '/edit/:id',    component: TravelEdit, as: 'Edit' }
])
@Component({
    selector: 'travel-app',
    template: `
        <h1>Angular 2 : Sample Travels Application</h1>
        <router-outlet></router-outlet>
    `,
    directives: [ROUTER_DIRECTIVES]
})
export class TravelApp {
    constructor() {
    }
}

bootstrap(TravelApp, [
    TravelService,
    ROUTER_PROVIDERS, HTTP_BINDINGS,
    provide(LocationStrategy, {useClass: HashLocationStrategy}),
    provide(APP_BASE_HREF, {useValue: '/'})
]);


開發者ID:israa-ia1205702,項目名稱:Examples,代碼行數:28,代碼來源:travel-app.ts

示例10: bootstrap

/// <reference path="typings/_custom.d.ts" />

import { provide, bootstrap } from 'angular2/angular2';
import { QUESTIONS } from './data/questions';
import { ROUTER_PROVIDERS, HashLocationStrategy, LocationStrategy } from 'angular2/router';
import { Devfest } from './app';

bootstrap(Devfest, [
	ROUTER_PROVIDERS, 
	provide(Array, {useValue: QUESTIONS}),
	provide(LocationStrategy, {useClass: HashLocationStrategy})
]);
開發者ID:QuinntyneBrown,項目名稱:angular2-dependencies-graph,代碼行數:12,代碼來源:bootstrap.ts


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