Ionic States

Hi,

Trouble with .state in an app that I am creating to learn ionic. Scourged the internet and forums but couldn’t find a break through.

I have 3 views: list.html, view.html and bill.html. When I add the state for the view ‘bill.html’, everything breaks. view.html contains a button, and upon clicking, it should display bill.html. Can you pls help to check why it breaks? Thanks for your time.

index.html:

Fork
<link href="lib/ionic/css/ionic.css" rel="stylesheet">

<script src="lib/ionic/js/ionic.bundle.js"></script>

<!-- Needed for Cordova/PhoneGap (will be a 404 during development) -->
<script src="js/app.js"></script>
<script src="cordova.js"></script>
Back

Add Bill {{input.description}}
</script -------------------------------------------------------------------------------------------------- app.js: var nameApp = angular.module('starter', ['ionic', 'ui.router']); nameApp.config(function($stateProvider, $urlRouterProvider) { $stateProvider .state('list', { url: '/', templateUrl: 'list.html', controller: 'ListCtrl' }) .state('view', { url: '/view', templateUrl: 'view.html', controller: 'ViewCtrl' }); $urlRouterProvider.otherwise("/"); }); nameApp.factory('event', function() { event = {}; event.description = ""; event.venue = ""; event.date = ""; return event; }); nameApp.controller('ListCtrl', function($scope, event) { $scope.input = event; }); nameApp.controller('ViewCtrl', function($scope, event) { $scope.input = event; });

Sorry, this is the .state parameter that I add to the app.js file and everything breaks after that.
.state(‘bill’, {
url: ‘/bill’,
templateUrl: ‘bill.html’,
controller: ‘BillController’
});

Could you please reformat you first message so the code is readable?
Also, how and where exactly do you add the bill state?
What does everything breaks? What error messages do you get when and where?

1 Like

Hi Sujan,

Sorry, I was away and had limited access and hence was not able to reply earlier. The issue was that I did not add $stateProvider in my state’bill’. I am now able to view the screens. Earlier on, all my screens would disappear if I added my state ‘bill’ to the app.js

Thanks for your time.

Regards,
Aj