0
votes

I am new in ionic and angular js some one can help . i spend two days to create link from one page to other but fail.



this is button which is on default tabs page like (dash). this is my controller :

.controller('DashCtrl', function($scope) {

       $scope.create = function () {
       alert("new post");
      $scope.go('templates/newspost');
  };

})

And this is my route

  .state('newspost', {
    url: '/newspost',
    abstract: true,
    templateUrl: 'templates/newspost.html'
  })

i dont know where i make mistake.

2
This is button : <button class="button button-icon ion-compose" ng-click="create()"></button> And newpost.html is a file in template directory.Muhammad talha
$scope.go('/newpost') - you should go to the url not the template that is specified in your state.mani

2 Answers

0
votes

You can also try this :

<button class="button button-icon ion-compose" ui-sref="newspost">New Posts</button>

Or you can also use anchor tag:

<a href="#/newspost">New Post</a>

Hope it will help you!!

0
votes

I think your syntax error.

 .controller('DashCtrl', function($scope) {
   $scope.create = function () {
   alert("new post");
  $scope.go('templates/newspost');  };})

you should write $state.go('templates/newspost') instead of $scope.go('templates/newspost') and also you should add $state to .controller function like this

.controller('DashCtrl', function($scope,$state)