Button click on opening the Page in ionic


#1

dsdsfsfsfsfsfsfsfdsfsfdhi I am new to this ionic dev I am trying to open the new page on button click.but when I put the alert() it will prompted.

index.html

Demo App

    <ion-content paging="true" class="has-header">
        <div>
            <img src="img/Logo.jpg" width="100%" height="auto" style="display:block;margin-left:auto;margin-right:auto;" />
            <img src="img/Team.jpg" width="70%" height="auto" style="display:block;margin-left:auto;margin-right:auto;" />
        </div>
        <div ng-controller="loginCtrl">
            <Button id="btnLogin" class="icon icon-right ion-log-in left button button-positive button-block   " style="border-radius:15px 15px 15px 15px;" ng-click="login('/login')">Login</Button>
        </div>
        <div>

        </div>
        <div class="bar  bar-footer bar-calm">
            <div class="title">
                Copyright <strong></strong></label>
            </div>

    </ion-content>

</ion-pane>
<!--<ion-nav-bar class="bar-stable">
    <ion-nav-bar-button class="button-icon"></ion-nav-bar-button>
</ion-nav-bar>
<ion-nav-view></ion-nav-view>

--> Routes.js

var app =angular.module(‘app’,[‘ngRoute’]);

app.config(function($stateProvider,$urlRouteProvider){

$stateProvider

   .state('login', {
    url: '/page2',
    templateUrl: 'templates/login.html',
    controller: 'loginCtrl'
})

$urlRouteProvider.otherwise('/page2');

});
controller.js

var app =angular.module(‘app’, []);

app.controller(‘loginCtrl’, function ($scope, $http,$stateprovider) {
$scope.login = function (path) {
$location.path(path);
alert(path);
};
});
Here I want to open the login.html page while clicking the Login button, but when I click it prompt the alert but I stuck while opening the login page

login.html

Username Password
Log in Or create an account

#2

Hi,
Please add a demo in the codepen.