How to create new page/template?


#1

I am working with sidemenu App and very new to Ionic (working from last 3 days).
I am wondering about where to add new page on click.
How can I add header to new content and show it on click?
I have created a new template and wrote my code but when i give this template path in browser - it redirects to default URL.

(Should i study Angular JS first to work on it?)
Please help !


#2

From your problem description it seems you are new to angular as well. Ionic uses [ui-router][1] for view routing. You need to define routes in module config to redirect your views to different pages.

     app.config(function($stateProvider, $urlRouterProvider) {
  //
  // For any unmatched url, redirect to /state1
  $urlRouterProvider.otherwise("/state1");
  //
  // Now set up the states
  $stateProvider
    .state('state1', {
      url: "/state1",
      templateUrl: "partials/state1.html"
    })
    .state('state1.list', {
      url: "/list",
      templateUrl: "partials/state1.list.html",
      controller: function($scope) {
        $scope.items = ["A", "List", "Of", "Items"];
      }
    })
    .state('state2', {
      url: "/state2",
      templateUrl: "partials/state2.html"
    })
    .state('state2.list', {
      url: "/list",
      templateUrl: "partials/state2.list.html",
      controller: function($scope) {
        $scope.things = ["A", "Set", "Of", "Things"];
      }
    });
});

Then on your ng-click call a function to redirect to desired view’s url.
[1]: https://github.com/angular-ui/ui-router


#3

Thanks for your reply :blush: