Reputation: 1177
I am learning angular2/ionic2 and I am trying to learn by creating small apps. This time I wanted to create an app to open an webpage (url). I got error (CANNOT FIND PLATFORM) and solved with help from Stack Overflow.
The app is successfully build but I could not run the app in real device. I am just getting a blank white screen. When I run ionic serve, I am getting runtime error. I have added my .ts file.
Home.ts
import {Page} from 'ionic-framework/ionic';
import { Platform } from 'ionic-angular';
declare var cordova:any;
@Page({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public platform: Platform) {
platform = platform;
}
launch(url) {
this.platform.ready().then(() => {
cordova.InAppBrowser.open(url, "_system", "location=true");
});
}
}
app.module.ts
import { NgModule, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import { AboutPage } from '../pages/about/about';
import { ContactPage } from '../pages/contact/contact';
import { HomePage } from '../pages/home/home';
import { TabsPage } from '../pages/tabs/tabs';
@NgModule({
declarations: [
MyApp,
AboutPage,
ContactPage,
HomePage,
TabsPage
],
imports: [
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
AboutPage,
ContactPage,
HomePage,
TabsPage
],
providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}]
})
export class AppModule {}
Upvotes: 0
Views: 1135
Reputation: 29635
Go through Angular Guide. And check here.
You should use Component
not page
.
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
Upvotes: 1