• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript core.provide函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中angular2/core.provide函数的典型用法代码示例。如果您正苦于以下问题:TypeScript provide函数的具体用法?TypeScript provide怎么用?TypeScript provide使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了provide函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: provide

// Angular 2
import {FORM_PROVIDERS} from 'angular2/common';

// Angular 2 Http
import {HTTP_PROVIDERS} from 'angular2/http';
// Angular 2 Router
import {ROUTER_PROVIDERS, APP_BASE_HREF} from 'angular2/router';

// Angular 2 Material
// import {MdRadioDispatcher} from '@angular2-material/radio/radio_dispatcher';
// const MATERIAL_PROVIDERS = [
//   MdRadioDispatcher
// ];

/*
 * Application Providers/Directives/Pipes
 * providers/directives/pipes that only live in our browser environment
 */
export const APPLICATION_PROVIDERS = [
    ...FORM_PROVIDERS,
    ...HTTP_PROVIDERS,
    // ...MATERIAL_PROVIDERS,
    ...ROUTER_PROVIDERS,
    provide(APP_BASE_HREF, {useValue: '/'}),
];

export const PROVIDERS = [
    ...APPLICATION_PROVIDERS
];
开发者ID:ASDAlexey,项目名称:angular2-jwt-express,代码行数:29,代码来源:providers.ts


示例2: createAppStoreFactoryWithOptions

import {bootstrap} from "angular2/platform/browser";
import {provide} from "angular2/core";
import {AppComponent} from "./app-component";

import {HTTP_PROVIDERS} from "angular2/http";
import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from "angular2/router";

import "angular2-materialize";

import {AppStore,createAppStoreFactoryWithOptions} from "angular2-redux";
import users from "./reducers/users-reducer";

const appStoreFactory = createAppStoreFactoryWithOptions({reducers:users,debug:true});

bootstrap(AppComponent, [
    provide(AppStore, {useFactory: appStoreFactory}),
    ROUTER_PROVIDERS, provide(LocationStrategy, {useClass: HashLocationStrategy}),
    HTTP_PROVIDERS
]);

/* tslint:disable */
// polyfill for Object.assign (not part of TS yet)
// https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
if (!Object.assign) {
    Object.defineProperty(Object, "assign", {
        enumerable: false,
        configurable: true,
        writable: true,
        value: function(target) {
            "use strict";
            if (target === undefined || target === null) {
开发者ID:Jefftopia,项目名称:angular2-tutorial,代码行数:31,代码来源:main.ts


示例3: beforeEachProviders

 beforeEachProviders(() => [
   provide(TestProviderConfig, {useValue: config}),
   TestProvider
 ]);
开发者ID:AlexYankee,项目名称:ng2-starter,代码行数:4,代码来源:test-provider.spec.ts


示例4: provide

import { provide } from 'angular2/core';
import { FIREBASE_BOOKS_URL } from '../../config';
import { AuthService } from '../auth/auth-service';
import { BookService } from './book-service';
import { BookStore } from './book-store';


export const BOOK_PROVIDERS: any[] = [
  provide(BookService, {
    deps: [AuthService],
    useFactory: (auth: AuthService): BookService => {
      return new BookService(new Firebase(`${FIREBASE_BOOKS_URL}/${auth.id}`));
    }
  }),

  provide(BookStore, {
    deps: [AuthService],
    useFactory: (auth: AuthService): BookStore => {
      return new BookStore(new Firebase(`${FIREBASE_BOOKS_URL}/${auth.id}`));
    }
  })
];
开发者ID:appmite,项目名称:karaoke-reading-web,代码行数:22,代码来源:book-providers.ts


示例5: bootstrap

import {provide} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
import {ROUTER_PROVIDERS, HashLocationStrategy, LocationStrategy} from 'angular2/router';

import {AppRouter} from './app.router';

bootstrap(AppRouter, [ROUTER_PROVIDERS, provide(LocationStrategy, {useClass: HashLocationStrategy})]);
开发者ID:Amzikan,项目名称:protractor,代码行数:7,代码来源:boot.ts


示例6: constructor

export class App {
  constructor(private authService: AuthService, private router: Router) { }

  isUserLogged(): boolean {
    return this.authService.isLogged();
  }

  getLoggedUser(): string {
    return this.authService.getLoggedUser();
  }

  logout(): void {
    this.authService.logout().subscribe((success) => {
      if (success) {
        this.router.navigate(['/Login']);
      }
    });
  }
}

bootstrap(App, [
  HTTP_PROVIDERS,
  servicesInjectables,
  AUTH_PROVIDERS,
  ROUTER_PROVIDERS,
  provide(APP_BASE_HREF, { useValue: '/' }),
  provide(LocationStrategy, { useClass: HashLocationStrategy })])
  .then((appRef) => {
    appInjector(appRef.injector);
  });
开发者ID:ebarabanovska,项目名称:OPEN_Launcher,代码行数:30,代码来源:app.ts


示例7: beforeEachProviders

 beforeEachProviders(() => [provide(TodoService, {useClass: MockTodoService})]);
开发者ID:AliMD,项目名称:generator-ng-fullstack,代码行数:1,代码来源:todo-cmp_test.ts


示例8: provide

import {MockBackend} from "angular2/src/http/backends/mock_backend";
import {BaseRequestOptions, Http} from "angular2/http";
import {MyHttp} from "./my-http";
import {provide} from "angular2/core";

export const CUSTOM_HTTP_PROVIDERS = [
    MockBackend,
    BaseRequestOptions,
    provide(Http, {
            useFactory: (backend, options) => {
                return new MyHttp(backend, options);
            },
            deps: [MockBackend, BaseRequestOptions]
        }
    )
];
开发者ID:Rachnerd,项目名称:angular2,代码行数:16,代码来源:index.ts


示例9: beforeEachBindings

 beforeEachBindings(() => { return [provide(APP_BASE_HREF, {useValue: '/my/app'})]; });
开发者ID:hankduan,项目名称:angular,代码行数:1,代码来源:router_integration_spec.ts


示例10: login

import { Injectable, provide } from 'angular2/core';

@Injectable()
export class AuthService {
    login(user: string, password: string): boolean {
        if (user === 'user' && password === 'password') {
            localStorage.setItem('username', user);
            return true;
        }

        return false;
    }

    logout(): any {
        localStorage.removeItem('username');
    }

    getUser(): any {
        return localStorage.getItem('username');
    }

    isLogged(): boolean {
        return this.getUser() !== null;
    }
}

export var AUTH_PROVIDERS: Array<any> = [
    provide(AuthService, {useClass: AuthService})
];
开发者ID:clankford,项目名称:angular2-routing,代码行数:29,代码来源:AuthService.ts



注:本文中的angular2/core.provide函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript core.AppViewManager类代码示例发布时间:2022-05-25
下一篇:
TypeScript core.platform函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap