-1

I am trying to do load an html page using angularJS.

My HTML page is like:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>TSAPI Profiles list</title>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://rawgit.com/angular/bower-angular/master/angular.min.js"></script>
<script src="main.js"></script>
<style type="text/css">
    .container{
        margin: 20px;
    }
</style>
</head>
<body>
    <div class="container" ng-app="TSAPIProfiles" ng-controller="TSAPIController">

        <div class="col-md-4">
        <p> <h4> TSAPI Profiles </h4> <br><br></p>
        </div>

        <table class="table table-bordered">

            <tbody>
                <tr>
                    <td>TSAPIProfile Name</td>
                    <td>ACD#</td>
                    <td>HUB...</td>
                </tr>
                <tr>
                    <td>AESServerPrimary</td>
                    <td>NorthACDTSAPI1</td>
                    <td>NorthACD</td>
                </tr>
                <tr>
                    <td>North</td>
                    <td>AESNorth1</td>
                    <td>ManualCBSDetails</td>
                </tr>
            </tbody>
        </table>
        <!-- Button -->
        <div class="btn-group-justified" >

              <div class="col-md-4" style="margin-left: 400px;" >
                <button name="savebutton" class="btn btn-primary" type="button" ng-click="add()">Add</button>
                <button name="resetbutton" class="btn btn-primary" type="button" ng-click="edit()">Edit</button>
                <button name="cancelbutton" class="btn btn-primary" type="button" ng-click="remove()">Remove</button>
              </div>
        </div>

    </div>
</body>
</html>   

And my JS file is like:

 var app = angular.module('TSAPIProfiles', [])
    app.controller('TSAPIController',['$scope','$location', function ($scope,$location) {
       $scope.add = function () {
        $location.path('TSAPIProfileCreate.html');
        }

    }]);

When I click on add button it doesn't load the TSAPIProfileCreate.html. I could not able to find the reason.

1
  • Try $location.url("your url") Commented Apr 25, 2017 at 15:02

2 Answers 2

0

Try to follow Manikandan answer because it's the right way to do this (or use ui-router), but if you really want to make a redirection like this, use : $window.location.href like this

Sign up to request clarification or add additional context in comments.

Comments

0

$location.path('TSAPIProfileCreate.html'); // This is bad

$location.path returns the part of the URL after the slash NOT including search string parameters (after the question mark).

Create View then use $location.path. https://docs.angularjs.org/api/ngRoute/directive/ngView

$location.path('TSAPIProfileCreate');

https://docs.angularjs.org/guide/$location

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.