I am new to ionic and trying different things while going through your articles and video tutorials which are very helpful. I created a very simple component and used ionic component ion-list inside this component. This component displays list but it does not apply ionic style.
Component JS Code:
import {Component, View, Input} from ‘angular2/angular2’;
@Component ({
selector: ‘todo-renderer’
})
@View ({
templateUrl: ‘app/todo/todorenderer.html’
})
export class TodoRenderer {
@Input() todos;
constructor(){
}
}
HTML Code:
<ion-list>
<ion-item *ng-for="#todo of todos" >{{todo.subject}}</ion-item>
</ion-list>
You have to import the Ionic components and register them as ‘directives’ :
import {Component} from 'angular2/angular2';
import {List, Item} from 'ionic/ionic';
@Component({
selector: 'test-list',
templateUrl: 'app/test-list/test-list.html',
directives: [List, Item]
})
export class TestList {
constructor() {
}
}
There is one thing missing still; I posted a question how to get a handle for those Ionic components inside the custom component – to use the methods. Seems the Ionic components inside a custom components do not register themselves into the IonicApp - so getComponent('id') is not working.
Try import {IONIC_DIRECTIVES} from 'ionic-framework/config/directives';@snikh
This will grab all the existing ionic components with no additional overhead.
Trying to get this to work, the icons aren’t rendering… What am I missing?
import {Component} from ‘angular2/core’;
import {NgIf} from ‘angular2/common’;
import {SocketService} from ‘…/services/socket.service’;
import {IONIC_DIRECTIVES} from ‘ionic-angular/config/directives’;
Another thing that I’m slightly confused on is I see the imports coming from various places, but the only one that doesn’t fail for me (with import) is
import {STUFF} from ‘ionic-angular’;
‘ionic/ionic’ doesn’t work or ‘ionic-framework’
I’ve tried several different to see if my import was just pulling the wrong classes in, but I’m getting no love with the icons. The curious thing is that the markup IS being transcluded, just the actual icons aren’t visible.