-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(js-native): support Angular RC5
- Loading branch information
Shlomi Assaf (shlassaf)
committed
Aug 10, 2016
1 parent
e4bbcc4
commit 2783d51
Showing
32 changed files
with
525 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/components/angular2-modal/framework/createComponent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { | ||
ComponentRef, | ||
ComponentFactoryResolver, | ||
ViewContainerRef, | ||
ReflectiveInjector, | ||
ResolvedReflectiveProvider | ||
} from '@angular/core'; | ||
|
||
export function createComponent(cfr: ComponentFactoryResolver, | ||
type: any, | ||
vcr: ViewContainerRef, | ||
bindings: ResolvedReflectiveProvider[]): ComponentRef<any> { | ||
return vcr.createComponent( | ||
cfr.resolveComponentFactory(type), | ||
vcr.length, | ||
getInjector(vcr, bindings) | ||
); | ||
} | ||
|
||
function getInjector(viewContainer: ViewContainerRef, bindings: ResolvedReflectiveProvider[]) { | ||
const ctxInjector = viewContainer.parentInjector; | ||
return Array.isArray(bindings) && bindings.length > 0 ? | ||
ReflectiveInjector.fromResolvedProviders(bindings, ctxInjector) : ctxInjector; | ||
|
||
} | ||
|
||
export default createComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/components/angular2-modal/plugins/js-native/js-native.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { Modal } from './modal'; | ||
import { JSNativeModalRenderer } from './js-native-modal-renderer'; | ||
import { JSNativePresetBuilder } from './presets/js-native-preset'; | ||
|
||
import { | ||
Modal as BaseModal, | ||
ModalBackdropComponent, | ||
ModalDropInFactory, | ||
ModalRenderer, | ||
DROP_IN_TYPE | ||
} from '../../angular2-modal'; | ||
|
||
function getProviders(): any[] { | ||
return [ | ||
{ provide: BaseModal, useClass: Modal }, | ||
{ provide: Modal, useClass: Modal }, | ||
{ provide: ModalRenderer, useClass: JSNativeModalRenderer }, | ||
{ provide: ModalBackdropComponent, useValue: {} }, | ||
{ provide: ModalDropInFactory, useValue: { | ||
alert: modal => new JSNativePresetBuilder(modal, DROP_IN_TYPE.alert), | ||
prompt: modal => new JSNativePresetBuilder(modal, DROP_IN_TYPE.prompt), | ||
confirm: modal => new JSNativePresetBuilder(modal, DROP_IN_TYPE.confirm) | ||
}} | ||
]; | ||
} | ||
|
||
@NgModule({ | ||
providers: getProviders() | ||
}) | ||
export class JSNativeModalModule { | ||
|
||
static getProviders(): any[] { | ||
return getProviders(); | ||
} | ||
|
||
} |
Oops, something went wrong.