本文整理汇总了TypeScript中angular2/core.Injector.resolveAndCreate方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Injector.resolveAndCreate方法的具体用法?TypeScript Injector.resolveAndCreate怎么用?TypeScript Injector.resolveAndCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/core.Injector
的用法示例。
在下文中一共展示了Injector.resolveAndCreate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: beforeEach
beforeEach(function() {
routeSet$ = new Subject<NextInstruction>();
spyOn(router, 'replace');
spyOn(observer, 'next');
const injector = Injector.resolveAndCreate([
provide(Router, { useValue: router })
]);
redirect = injector.resolveAndInstantiate(redirectMiddleware);
});
示例2: beforeEach
beforeEach(() => {
var injector = Injector.resolveAndCreate(
[provide(ResponseOptions, {useClass: BaseResponseOptions}), MockBackend]);
backend = injector.get(MockBackend);
var base = new BaseRequestOptions();
sampleRequest1 = new Request(base.merge(new RequestOptions({url: 'https://google.com'})));
sampleResponse1 = new Response(new ResponseOptions({body: 'response1'}));
sampleRequest2 = new Request(base.merge(new RequestOptions({url: 'https://google.com'})));
sampleResponse2 = new Response(new ResponseOptions({body: 'response2'}));
});
示例3: beforeEach
beforeEach(() => {
injector = Injector.resolveAndCreate([
HTTP_PROVIDERS,
GithubComponent,
GithubService,
Config
]);
component = injector.get(GithubComponent);
service = injector.get(GithubService);
sinon.spy(service, "searchRepositories");
});
示例4:
//nextRoute, CurrentRoute instructions
(nextInstr: any, currInstr: any) => {
//Weâre first asking the Injector class to give us a concrete injector that is aware of only once class: AuthService.
let injector: any = Injector.resolveAndCreate([AuthService]);
//Next, weâre asking this injector to give us an instance of that class.
let authService: AuthService = injector.get(AuthService);
console.log('nextInstr', nextInstr);
console.log('currInstr', currInstr);
return authService.isLogged();
}
示例5: createStore
function createStore(reducer, monitorReducer = T => T){
const injector = Injector.resolveAndCreate([
provideStore(reducer),
instrumentStore(monitorReducer)
]);
const store = injector.get(Store);
const devtools = injector.get(StoreDevtools);
return { store, devtools };
}
示例6: inject
return inject(tokens, (tcb, router, location, backend, userService, loginService) => {
// TODO it's not a good idea, but I have no other way.
// It must be resolved in https://github.com/angular/angular/issues/4112
appInjector(Injector.resolveAndCreate([
provide(UserService, {useValue: userService}),
provide(LoginService, {useValue: loginService}),
provide(Router, {useValue: router}),
]));
const ctx = new TestContext({tcb, router, location, backend});
fn(ctx);
});
示例7: it
it('should alias devtools to the store backend', () => {
const injector = Injector.resolveAndCreate([
provideStore(counter),
instrumentStore()
]);
const devtools = injector.get(StoreDevtools);
const backend = injector.get(StoreBackend);
expect(devtools).toBe(backend);
});
示例8: value
function value(snapshot: FirebaseDataSnapshot) {
let child = snapshot.val();
child[keyFieldName] = snapshot.key();
if (type && Ng2Firebase.appRef) {
let providers = [provide(FirebaseData, {useValue: child})];
let injector = Ng2Firebase.appRef.injector;
if (!opts.load) injector = Injector.resolveAndCreate([]);
let childInjector = injector.resolveAndCreateChild(providers);
child = childInjector.resolveAndInstantiate(type);
}
observer.next(child);
}
示例9: beforeEach
beforeEach(() => {
injector = Injector.resolveAndCreate([
HTTP_PROVIDERS,
// Provide a mocked (fake) backend for Http
provide(XHRBackend, {useClass: MockBackend}),
TranslateService
]);
backend = injector.get(XHRBackend);
translate = injector.get(TranslateService);
// sets the connection when someone tries to access the backend with an xhr request
backend.connections.subscribe((c: MockConnection) => connection = c);
});
示例10: beforeEach
beforeEach(() => {
injector = Injector.resolveAndCreate([
HTTP_PROVIDERS,
MockBackend,
provide(XHRBackend, {useClass: MockBackend}),
First
]);
mockBackend = injector.get(MockBackend);
backend = injector.get(XHRBackend);
httpService = injector.get(Http);
_first = injector.get(First);
});