mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
chore(): remove use of @View
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {Component, Directive, View, ElementRef, Host, Optional, forwardRef, Inject, NgZone, Compiler, AppViewManager, DynamicComponentLoader, Renderer, ViewContainerRef} from 'angular2/angular2';
|
||||
import {Component, Directive, ElementRef, Host, Optional, forwardRef, Inject, NgZone, Compiler, AppViewManager, DynamicComponentLoader, Renderer, ViewContainerRef} from 'angular2/angular2';
|
||||
|
||||
import {IonicApp} from '../app/app';
|
||||
import {IonicConfig} from '../../config/config';
|
||||
@@ -129,9 +129,7 @@ import {NavController} from './nav-controller';
|
||||
],
|
||||
defaultInputs: {
|
||||
'swipeBackEnabled': true
|
||||
}
|
||||
})
|
||||
@View({
|
||||
},
|
||||
template: '<template pane-anchor></template>',
|
||||
directives: [forwardRef(() => NavPaneAnchor)]
|
||||
})
|
||||
@@ -405,9 +403,7 @@ class ContentAnchor {
|
||||
* @private
|
||||
*/
|
||||
@Component({
|
||||
selector: 'ion-pane'
|
||||
})
|
||||
@View({
|
||||
selector: 'ion-pane',
|
||||
template:
|
||||
'<section class="navbar-container">' +
|
||||
'<template navbar-anchor></template>' +
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
import {
|
||||
Directive,
|
||||
Component,
|
||||
View,
|
||||
bootstrap,
|
||||
Injectable,
|
||||
Inject,
|
||||
forwardRef,
|
||||
Inject,
|
||||
DynamicComponentLoader,
|
||||
ElementRef,
|
||||
Query,
|
||||
QueryList,
|
||||
ComponentRef
|
||||
} from 'angular2/angular2';
|
||||
|
||||
|
||||
@Injectable()
|
||||
class IonicModal {
|
||||
constructor() {
|
||||
console.log('IonicModal constructor');
|
||||
}
|
||||
open(componentType) {
|
||||
console.log('IonicModal open:', componentType.name);
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
class UserService {
|
||||
constructor() {
|
||||
console.log('UserService constructor');
|
||||
this.id = Math.random();
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({
|
||||
selector: 'button',
|
||||
host: {
|
||||
'ionic-button': 'true'
|
||||
}
|
||||
})
|
||||
class IonicButton {
|
||||
constructor() {
|
||||
console.log('IonicButton')
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({
|
||||
selector: 'button',
|
||||
host: {
|
||||
'user-button': 'true'
|
||||
}
|
||||
})
|
||||
class UserButton {
|
||||
constructor() {
|
||||
console.log('UserButton')
|
||||
}
|
||||
}
|
||||
|
||||
var IONIC_DIRECTIVES = [IonicButton];
|
||||
|
||||
@Component({
|
||||
selector: 'user-modal'
|
||||
})
|
||||
@View({
|
||||
template: `
|
||||
<div style="position:absolute;top:0;right:0;bottom:0;left:0;background:#ddd;">
|
||||
<h2>user modal</h2>
|
||||
<p>UserService: {{userService.id}}
|
||||
</div>
|
||||
`
|
||||
})
|
||||
class UserModal {
|
||||
constructor(userService: UserService) {
|
||||
console.log('UserModal constructor');
|
||||
this.userService = userService;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'user-app',
|
||||
hostInjector: [UserService]
|
||||
})
|
||||
@View({
|
||||
template: `
|
||||
<h1>user root component</h1>
|
||||
<button (click)="openModal()">Open Modal</button>
|
||||
<ng-content></ng-content>
|
||||
`,
|
||||
directives: IONIC_DIRECTIVES.concat([UserButton])
|
||||
})
|
||||
class UserRootComponent {
|
||||
constructor(ionicModal: IonicModal, userService: UserService) {
|
||||
console.log('UserRootComponent constructor');
|
||||
this.ionicModal = ionicModal;
|
||||
}
|
||||
openModal(){
|
||||
this.ionicModal.open(UserModal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Directive({
|
||||
selector: 'overlay-anchor'
|
||||
})
|
||||
class OverlayAnchor {
|
||||
constructor(
|
||||
userService: UserService,
|
||||
public elementRef: ElementRef,
|
||||
loader: DynamicComponentLoader)
|
||||
{
|
||||
console.log('OverlayAnchor constructor', userService);
|
||||
loader.loadNextToLocation(UserModal, elementRef).then((ref: ComponentRef) => {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function ionicApp(userApp: Type) {
|
||||
function IonicRootComponent() {}
|
||||
IonicRootComponent.annotations = [
|
||||
new Component({
|
||||
selector: 'ion-app',
|
||||
viewInjector: [IonicModal]
|
||||
}),
|
||||
new View({
|
||||
template: `
|
||||
<user-app>
|
||||
<overlay-anchor></overlay-anchor>
|
||||
</user-app>`,
|
||||
directives: [userApp, OverlayAnchor]
|
||||
})
|
||||
];
|
||||
return IonicRootComponent;
|
||||
}
|
||||
|
||||
console.log('bootstrap')
|
||||
bootstrap(ionicApp(UserRootComponent)).catch(err => {
|
||||
console.error('bootstrap', err);
|
||||
});
|
||||
Reference in New Issue
Block a user