0

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");
});

}

}

enter image description here

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 {}

enter image description here

5
  • 2
    can you add your app.module.ts file to the question? Commented Mar 21, 2017 at 8:28
  • yes..,one moment Commented Mar 21, 2017 at 8:34
  • 1
    import {Page} from 'ionic-framework/ionic'; What is this line for? Are you using any component by name 'Page' if so, are you importing it correctly? Commented Mar 21, 2017 at 8:34
  • @Page({ selector: 'page-home', templateUrl: 'home.html' }) Commented Mar 21, 2017 at 8:42
  • i think yes.., i imported it correctly..,app is successfully build too Commented Mar 21, 2017 at 8:43

1 Answer 1

1

Go through Angular Guide. And check here. You should use Component not page.

@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
Sign up to request clarification or add additional context in comments.

4 Comments

thank you once again @suraj., this has been solved but still i am getting different runtime error
i have added a picture of of it. runtime error:cordova is not defined in Homepage
cordova does not work in ionic serve.. it only loads in device/emulator
yes you are correct but i just want to launch a url(fr eg.,google)..,i have created a button and if i click the button I am getting the above mentioned error.Now the app is visible in real device but i COULDN't load the webpage

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.