2015-10-29 68 views
0

我想點擊這裏按鈕移動到另一頁是我的代碼:如何創建一個根點擊按鈕angularjs

var app= angular.module("MyUser",[]); 
app.controller("UtilisateurControleur",function($scope,$http) 
{$scope.list=[]; 
    $scope.Utilisateur=[]; 
    $scope.i=0; 
     $scope.login = function(user) { 

    $http.get("/allU").success(function(response) { 
     $scope.list = response; 
     $scope.nameList = []; 
     var a=response.length; 
     angular.forEach($scope.list,function(Obj,val){ 

      if (user.login===Obj.login && user.password===Obj.password) 
      { 
       console.log("Hi "+Obj.nom+" You are in the system"); 
      } 

的,如果我想傳遞給一個HTML頁面後:/頁html的。我怎麼能解決這個問題

回答

0

注入$ ngRoute過的應用程序模塊和$位置控制器,然後嘗試以下

$location.path('/page') 

,並在App.config您可以使用下面

$routProvider.when ('/page',{ 
    templateUrl : '/page.html'; 
}) 
+0

我添加這個js文件: –

+0

我不明白你的意思 –

+0

請參閱我所寫 –

0
代碼

您可以使用角$window

$window.location.href = '/index.html'; 
0
var app = angular.module('MyUser', ['ngRoute']); 

app.config(['$routeProvider', function($routeProvider) { 
    $routProvider.when ('/page',{ 
     templateUrl : '/pages/Accueil.html'; 
    }) 
    }]); 


app.controller("UtilisateurControleur",function($scope,$http,$location) 
{$scope.list=[]; 
    $scope.Utilisateur=[]; 
    $scope.i=0; 
     $scope.login = function(user) { 

    $http.get("/allU").success(function(response) { 
     $scope.list = response; 
     $scope.nameList = []; 
     var a=response.length; 
     angular.forEach($scope.list,function(Obj,val){ 

      if (user.login===Obj.login && user.password===Obj.password) 
      {$location.path('/page'); 
       console.log("Hi "+Obj.nom+" You are in the system"); 
      } 

      }); 
}); 


     }; 

}); 

這是我的控制器的代碼,我沒有找到問題。

相關問題