How to navigate from one page to another in ionic - angularjs

Ionic v1
I was using ui-sref to simply navigate from one page to another in my ionic app, but recently have to switch to $state.go because pressing button closes the app. I figured it out that states are not maintained in ui-sref.
So my question is do I have to always use $state.go if I just want to simply navigate between pages without closing my app and create a separate function in controller to go to next page.
Code for ref
<button class=" button button-assertive" ui-sref="nextPage">Next</a>
or
<button class=" button button-assertive" ng-click="gotonext()">Next</a>
JS
$scope.gotonext = function(){
$state.go('nextPage')
};

Try this :-
$scope.gotonext = function(){
$location.path("/nextPage");
};

Related

AngularJS reset whole application

I am currently working on a hotel booking app using Ionic 1 and AngularJS.
When the room is booked you will be greeted by a ng-modal popup with your room Information and contact info etc etc.
I implemented a button that takes the user out of the modal window and back to the home page like this.
<a href="#tab/home" style="text-decoration: none;">
<button class="button button-large button-balanced col" ng-click="modal.hide()" >
<p style="color: white; font-size: 20px;">Thank you</p>
</button>
I also want that same button to reset the whole application, is there an easy way to do this?
Thank you:)
When the modal window gets closed you are getting back to the parent controller, have a function implemented resetting the form and call the function.
$scope.reset = function(){
}
call it when you return back to the parent controller.

Ugly Url with in single page Angularjs

I have a <div id="section1"> </div> at the bottom of my page.
And I have a button I want this functionality in button
$location.hash('section1');
$anchorScroll();
It is working as I want but it is giving me ugly url all this is in single page than why my url is updating?
my expecting Url is :
/Order/BuildOrder
when page load I get this but when I click button screen took me to my anchor div with id='section1'
but now url change to /Order/BuildOrder#!#section1
How can I remove #!# as this is scrolling on a single page. href location is not changing

AngularJS redirct to page and open modal

I have a page that has a navbar on it. when you click on a button in the navbar it should redirect you to a search page, and open a modal dialog. I'm not sure what I'm doing wrong, but it won't redirect to the page I've specified in the ng-click directive and the modal only opens when it has the search page open. Here's my button in the navbar
<button class="btn default-btn advancedbtn" data-toggle="modal" data-target="#myModal" ng-click="redirect()">Advanced</button>
Here's the code to redirect in my controller:
$scope.redirect = function () {
$location.url('/search');
}
I'm probably going about this in the wrong way. If any other code is needed let me know. Thanks.

In AngularJS how do I open download pdf in new Tab on iPad browser using ng-click

On click of following button PDF download starts in the browser
<input name="SavNSend" class="gradient_button" id="printPdf" type="button" value="Save to PDF" ng-click="savePdfRP()"></input>
But what I want is to open a new tab in order to download the pdf. Can this be achieved using ng-click with button or ng-click with tag.
If you want to open a new tab/window. You need to use lower level services such as $window.
ng-click="savePdfRP()"
$scope.savePdfRP= function() {
$window.open(url, windowName);
}
Another approach is to bind the href of the anchor.
<a class="gradient_button" id="printPdf" ng-href="{{ url }}" target="_blank">Save to PDF</a>
$scope.url = 'http://www.google.com';

How to make simple button navigation in ionic with angularjs

I'm making a functional button in my ionic app, and I want to know what I need to do to make a button centered on a blank ionic app load another page when clicked.
I have experimented with adding ng-click="loadPage()" to the button in my index.html file. I defined
$scope.loadPage = function() { $state.go(page.html)} in my controller.
switch your button with an anchor
<a class="btn btn-full" ui-sref="your.state">your text</a>

Resources