Skip to content

Commit df32836

Browse files
committed
chore(id): finding component by an id attr has been removed
BREAKING CHANGES: app.getComponent() has been removed. Please use Angular's ViewChild annotation instead: http://learnangular2.com/viewChild/
1 parent 4fca31e commit df32836

File tree

4 files changed

+7
-139
lines changed

4 files changed

+7
-139
lines changed

ionic/components.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export * from './components/app/app';
2-
export * from './components/app/id';
32
export * from './components/action-sheet/action-sheet';
43
export * from './components/alert/alert';
54
export * from './components/badge/badge';

ionic/components/app/app.ts

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {Platform} from '../../platform/platform';
1212
*/
1313
@Injectable()
1414
export class IonicApp {
15-
private _cmps: {[id: string]: any} = {};
1615
private _disTime: number = 0;
1716
private _scrollTime: number = 0;
1817
private _title: string = '';
@@ -145,59 +144,20 @@ export class IonicApp {
145144

146145
/**
147146
* @private
148-
* Register a known component with a key, for easy lookups later.
149-
* @param {string} id The id to use to register the component
150-
* @param {object} component The component to register
151-
*/
152-
register(id: string, component: any) {
153-
this._cmps[id] = component;
154-
}
155-
156-
/**
157-
* @private
158-
* Unregister a known component with a key.
159-
* @param {string} id The id to use to unregister
160-
*/
161-
unregister(id: string) {
162-
delete this._cmps[id];
163-
}
164-
165-
/**
166-
* @private
167-
* Get a registered component with the given type (returns the first)
168-
* @param {object} cls the type to search for
169-
* @return {object} the matching component, or undefined if none was found
170147
*/
171148
getRegisteredComponent(cls: any): any {
172-
for (let key in this._cmps) {
173-
const component = this._cmps[key];
174-
if (component instanceof cls) {
175-
return component;
176-
}
177-
}
149+
// deprecated warning: added 2016-04-28, beta7
150+
console.warn('Using app.getRegisteredComponent() to query components has been deprecated. ' +
151+
'Please use Angular\'s ViewChild annotation instead:\n\nhttp://learnangular2.com/viewChild/');
178152
}
179153

180154
/**
181-
* Get the component for the given key.
155+
* @private
182156
*/
183157
getComponent(id: string): any {
184-
// deprecated warning
185-
if (/menu/i.test(id)) {
186-
console.warn('Using app.getComponent(menuId) to control menus has been deprecated as of alpha55.\n' +
187-
'Instead inject MenuController, for example:\n\n' +
188-
'constructor(menu: MenuController) {\n' +
189-
' this.menu = menu;\n' +
190-
'}\n' +
191-
'toggleMenu() {\n' +
192-
' this.menu.toggle();\n' +
193-
'}\n' +
194-
'openRightMenu() {\n' +
195-
' this.menu.open("right");\n' +
196-
'}'
197-
);
198-
}
199-
200-
return this._cmps[id];
158+
// deprecated warning: added 2016-04-28, beta7
159+
console.warn('Using app.getComponent() to query components has been deprecated. ' +
160+
'Please use Angular\'s ViewChild annotation instead:\n\nhttp://learnangular2.com/viewChild/');
201161
}
202162

203163
/**

ionic/components/app/id.ts

Lines changed: 0 additions & 89 deletions
This file was deleted.

ionic/config/directives.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import {Nav} from '../components/nav/nav';
3838
import {NavPush, NavPop} from '../components/nav/nav-push';
3939
import {NavRouter} from '../components/nav/nav-router';
4040
import {NavbarTemplate, Navbar} from '../components/navbar/navbar';
41-
import {IdRef} from '../components/app/id';
4241
import {ShowWhen, HideWhen} from '../components/show-hide-when/show-hide-when';
4342

4443
/**
@@ -211,7 +210,6 @@ export const IONIC_DIRECTIVES = [
211210
NavPush,
212211
NavPop,
213212
NavRouter,
214-
IdRef,
215213

216214
ShowWhen,
217215
HideWhen

0 commit comments

Comments
 (0)