当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript core.bind函数代码示例

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


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

示例1: fuseBootstraper

export function fuseBootstraper(customProviders: ProviderArray = null): ApplicationRef {
    FuseDomAdapter.makeCurrent();
    let platformProviders: ProviderArray = [
        PLATFORM_COMMON_PROVIDERS
    ];

    let defaultAppProviders: ProviderArray = [
        FuseRenderer,
        provide(Renderer, {
            useClass: FuseRenderer
        }),
        FuseRootRenderer,
        provide(RootRenderer, {
            useClass: FuseRootRenderer
        }),
        provide(XHR, {
            useClass: FileSystemXHR
        }),
        provide(ExceptionHandler, {
            useFactory: () => new ExceptionHandler(DOM, true),
            deps: []
        }),

        provide(PLATFORM_PIPES, {
            useValue: COMMON_PIPES,
            multi: true
        }),
        provide(PLATFORM_DIRECTIVES, {
            useValue: COMMON_DIRECTIVES,
            multi: true
        }),

        APPLICATION_COMMON_PROVIDERS,
        COMPILER_PROVIDERS,
        FORM_PROVIDERS,
        HTTP_PROVIDERS,
        ROUTER_PROVIDERS,
        bind(LocationStrategy).toClass(FuseLocationStrategy)
        // ROUTER_PROVIDERS,
        // provide(LocationStrategy, {
        //     useClass: FuseLocationStrategy
        // })
    ];

    let appProviders = [defaultAppProviders];
    if (isPresent(customProviders)) {
        appProviders.push(customProviders);
    }
    if (!_platform) {
        _platform = platform(platformProviders);
    }

    let app = _platform.application(appProviders);
    return app;
}
开发者ID:saikonda,项目名称:cruise-pas-public,代码行数:55,代码来源:bootstrap.ts

示例2: constructor

    { path: '/stats', component: Stats, as: 'Stats' }
])
class App {
    authUser: AuthUser;
    navOpen: boolean;
    
    constructor(private _authService: AuthService) { }
    
    ngOnInit() {
        this._authService.authUser$.subscribe(user => this.authUser = user);
        this._authService.loadAuthUser();
        this.navOpen = false;
    }
    
    logout() {
        this._authService.logout();
    }
}

bootstrap(App, [
    ROUTER_BINDINGS,
    FORM_BINDINGS,
    HTTP_BINDINGS,
    bind(ROUTER_PRIMARY_COMPONENT).toValue(App),
    bind(LocationStrategy).toClass(HashLocationStrategy),
    [
        DataService,
        AuthService,
        NotificationService
    ]
]);
开发者ID:splintercode,项目名称:psi-dashboard,代码行数:31,代码来源:app.ts

示例3: bootstrap

import * as router from 'angular2/router';
import {bootstrap}    from 'angular2/platform/browser';
import {bind, provide} from 'angular2/core';
import {App} from './app';
import {HTTP_PROVIDERS, Http} from 'angular2/http';

bootstrap(App, [
    router.ROUTER_PROVIDERS,
    bind(router.APP_BASE_HREF).toValue(location.pathname),
    provide(router.LocationStrategy, {useClass: router.HashLocationStrategy}),
    HTTP_PROVIDERS
]);
开发者ID:PatrickDinh,项目名称:hello-angular2,代码行数:12,代码来源:bootstrap.ts

示例4: bootstrap

import {DataTableExample} from './screens/datatable/DataTableExample';
import {ReferenceData, ReferenceDataService} from './common/referenceData';
import {NV_LAYOUT_DIRECTIVES} from 'angular-velocity';

@Component({
    selector: 'app',
    viewBindings: [ReferenceDataService]
})
@RouteConfig([
    { path: '/', component: Main, as: 'Home' },
    { path: '/data-table-example', component: DataTableExample, as: 'DataTableExample' }

])
@View({
    templateUrl: 'showcase/demo-app.html',
    directives: [RouterOutlet, RouterLink, NV_LAYOUT_DIRECTIVES]
})
class DemoApp {


}

bootstrap(
    DemoApp,
    [
        ReferenceDataService,
        ROUTER_BINDINGS,
        FORM_BINDINGS,
        bind(ROUTER_PRIMARY_COMPONENT).toValue(DemoApp)
    ]);
开发者ID:jhades,项目名称:angular-velocity,代码行数:30,代码来源:DemoApp.ts

示例5: saveUserSettingsForUser

      case DeviceType.Joystick:
        return 'JOYSTICK';
      case DeviceType.Key:
        return 'KEY';
      case DeviceType.KeyTrackball:
        return 'KEY_AND_TRACKBALL';
      case DeviceType.KeyJoystick:
        return 'KEY_AND_JOYSTICK';
      default:
        return 'MOUSE';
    }
  }

  saveUserSettingsForUser(username: string, userSettings: UserSettings): Observable<UserSettings> {
    let headers = new Headers();
    headers.append('Content-Type', 'application/json');

    return this.http.post(this.globalService.URL_SAVE_USERSETTINGS(username),
      JSON.stringify(userSettings),
      { headers: headers })
      .map(res => {
        let settings: UserSettings = res.json();
        return settings;
      });
  }
}

export let userSettingsServiceInjectables: Array<any> = [
  bind(UserSettingsService).toClass(UserSettingsService)
];
开发者ID:eljesaz,项目名称:OPEN_Launcher,代码行数:30,代码来源:UserSettingsService.ts

示例6: log

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

@Injectable()
export class LoggerService {
    log(msg: any) { console.log(msg); }
    error(msg: any) { console.error(msg); }
    warn(msg: any) { console.warn(msg); }
}

export var LoggerServiceInjectables: Array<any> = [
    bind(LoggerService).toClass(LoggerService)
];
开发者ID:solutionzero,项目名称:ng2-asp5-identity3-starter,代码行数:12,代码来源:logger.service.ts

示例7: addUser

  }

  //Add new user to db
  addUser(user: User) {
    var headers = new Headers();
    headers.append('Content-Type', 'application/json');

    return this.http.post(this.globalService.URL_ADDUSER,
      JSON.stringify(user),
      { headers: headers })
      .map(res => {
        var result = res.json();
        var response = new Users(result.data);
        return { users: response.users, message: result.message };
      });
  }

  //Delete user by name from db
  deleteUser(name) {
    return this.http.get(this.globalService.URL_DELETEUSER(name))
      .map(res => {
        var response = new Users(res.json());
        return response.users;
      });
  }
}

export var userServiceInjectables: Array<any> = [
  bind(UserService).toClass(UserService)
];
开发者ID:jovan1ivanovski,项目名称:OPEN_Launcher,代码行数:30,代码来源:UserService.ts

示例8: bootstrap

import {bootstrap}    from 'angular2/platform/browser'
import {bind} from 'angular2/core';
import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from 'angular2/router';
import {HTTP_BINDINGS} from 'angular2/http';
import {O365App} from './components/app'
bootstrap(O365App, [ROUTER_PROVIDERS, HTTP_BINDINGS, bind(LocationStrategy).toClass(HashLocationStrategy)]);
开发者ID:AdrianDiaz81,项目名称:n2-O365,代码行数:6,代码来源:boot.ts

示例9: constructor

import {Observer} from 'rxjs/Observer';
import {Subject} from 'rxjs/Subject';

import {Action} from './flux-action';
import {StateKeeper} from './flux-state';


// -- DI config
/*
  DI設定。Fluxの要。ViewとLogicを巧妙に分離している。理解に至るまでの道のりは長い。ひたすら難しい。こんなことを考案したのは一体誰だ。
  それでもここが理解できないとSavkin's Redux with RxJS for Angular2は理解できない。調べるにあたっては英語力とググり能力が試される最大の難所と言っても良い。
  https://laco0416.github.io/post/platform-prividers-of-angular-2/ を参考にすると理解の助けになるかもしれない。
  Providerはprovide()で書いても良いが個人的にはbind()の方が書きやすくて好きだ。provideはGrunt、bindはGulpみたいな違い。
*/

// RxJSのSubjectクラスを継承してDispatcherクラスを作る。このクラスはDIで使う。
// Dispatcherをクラスとして用意しておくことでComponentのDIに関する記述がシンプルになる。シンプルさは正義である。
export class Dispatcher<T> extends Subject<T> { 
  constructor(destination?: Observer<T>, source?: Observable<T>) { // この記述はRxJSのソースからパクった。
    super(destination, source);
  }
}

// TodoAppコンポーネントのprovidersにセットしており、Angular2のbootstrap()時にインスタンス化されComponentに紐付けられる。(@laco0416 さんありがとう!)
// StateKeeperのインスタンスを生成するときにinitStateとdispatcherを引数にあてている(クロージャしている)ので、
// Componentでdispatcher.next()をコールしたときにStateKeeper内部のObservable(scan)のscanサイクルを回すことができる。
export const stateAndDispatcher = [
  bind('initState').toValue({ todos: [], visibilityFilter: 'SHOW_ALL' } as AppState), // Componentから参照しないのでOpaqueTokenは使っていない。
  bind(Dispatcher).toValue(new Dispatcher<Action>(null)), // 超重要。これが全てを一つの輪に紡ぎ上げる。Savkin's Fluxの循環サイクルを理解できたとき、人は悟りを知るだろう。
  bind(StateKeeper).toFactory((state, dispatcher) => new StateKeeper(state, dispatcher), ['initState', Dispatcher]) // toFactoryの第二引数はTokenの配列であることに注意。bootstrap時にTokenを通じて値がStateKeeperの引数にあてられる。
];
开发者ID:ovrmrw,项目名称:savkins-angular2-rxjs-redux,代码行数:31,代码来源:flux-di.ts

示例10: bootstrap

import { bootstrap }    from 'angular2/platform/browser';
import { AppComponent } from './app.component';
import { HTTP_PROVIDERS } from 'angular2/http';
import { DataService } from './data.service';
import { bind } from 'angular2/core';
import { ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy } from "angular2/router";
// import { COMMON_DIRECTIVES } from 'angular2/platform/browser';
import 'rxjs/Rx';

bootstrap(AppComponent, [HTTP_PROVIDERS, ROUTER_PROVIDERS, bind(LocationStrategy).toClass(HashLocationStrategy), DataService]);
开发者ID:waitbutmetho,项目名称:Budtendr,代码行数:10,代码来源:main.ts


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