2017-04-25 43 views
-1

我正在尝试使用angulerJS加载html页面。

我的HTML页面是这样的:

<!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> 

而我的JS文件是这样的:

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

    }]); 

当我点击添加按钮也不会加载TSAPIProfileCreate.html。我无法找到原因。

+0

尝试 $ location.url( “网址”) – MukulSharma

回答

0

尝试按照Manikandan答案,因为它是这样做(或使用ui-router)以正确的方式,但如果你真的想这样的重定向,使用:$window.location.hrefthis