當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。