Skip to content

Commit

Permalink
chore(id): finding component by an id attr has been removed
Browse files Browse the repository at this point in the history
BREAKING CHANGES: app.getComponent() has been removed. Please use
Angular's ViewChild annotation instead:
http://learnangular2.com/viewChild/
  • Loading branch information
adamdbradley committed Apr 28, 2016
1 parent 4fca31e commit df32836
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 139 deletions.
1 change: 0 additions & 1 deletion ionic/components.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './components/app/app';
export * from './components/app/id';
export * from './components/action-sheet/action-sheet';
export * from './components/alert/alert';
export * from './components/badge/badge';
Expand Down
54 changes: 7 additions & 47 deletions ionic/components/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {Platform} from '../../platform/platform';
*/
@Injectable()
export class IonicApp {
private _cmps: {[id: string]: any} = {};
private _disTime: number = 0;
private _scrollTime: number = 0;
private _title: string = '';
Expand Down Expand Up @@ -145,59 +144,20 @@ export class IonicApp {

/**
* @private
* Register a known component with a key, for easy lookups later.
* @param {string} id The id to use to register the component
* @param {object} component The component to register
*/
register(id: string, component: any) {
this._cmps[id] = component;
}

/**
* @private
* Unregister a known component with a key.
* @param {string} id The id to use to unregister
*/
unregister(id: string) {
delete this._cmps[id];
}

/**
* @private
* Get a registered component with the given type (returns the first)
* @param {object} cls the type to search for
* @return {object} the matching component, or undefined if none was found
*/
getRegisteredComponent(cls: any): any {
for (let key in this._cmps) {
const component = this._cmps[key];
if (component instanceof cls) {
return component;
}
}
// deprecated warning: added 2016-04-28, beta7
console.warn('Using app.getRegisteredComponent() to query components has been deprecated. ' +
'Please use Angular\'s ViewChild annotation instead:\n\nhttp://learnangular2.com/viewChild/');
}

/**
* Get the component for the given key.
* @private
*/
getComponent(id: string): any {
// deprecated warning
if (/menu/i.test(id)) {
console.warn('Using app.getComponent(menuId) to control menus has been deprecated as of alpha55.\n' +
'Instead inject MenuController, for example:\n\n' +
'constructor(menu: MenuController) {\n' +
' this.menu = menu;\n' +
'}\n' +
'toggleMenu() {\n' +
' this.menu.toggle();\n' +
'}\n' +
'openRightMenu() {\n' +
' this.menu.open("right");\n' +
'}'
);
}

return this._cmps[id];
// deprecated warning: added 2016-04-28, beta7
console.warn('Using app.getComponent() to query components has been deprecated. ' +
'Please use Angular\'s ViewChild annotation instead:\n\nhttp://learnangular2.com/viewChild/');
}

/**
Expand Down
89 changes: 0 additions & 89 deletions ionic/components/app/id.ts

This file was deleted.

2 changes: 0 additions & 2 deletions ionic/config/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import {Nav} from '../components/nav/nav';
import {NavPush, NavPop} from '../components/nav/nav-push';
import {NavRouter} from '../components/nav/nav-router';
import {NavbarTemplate, Navbar} from '../components/navbar/navbar';
import {IdRef} from '../components/app/id';
import {ShowWhen, HideWhen} from '../components/show-hide-when/show-hide-when';

/**
Expand Down Expand Up @@ -211,7 +210,6 @@ export const IONIC_DIRECTIVES = [
NavPush,
NavPop,
NavRouter,
IdRef,

ShowWhen,
HideWhen
Expand Down

0 comments on commit df32836

Please sign in to comment.