AngularJS路由在PhoneGap中无法正常工作

sel*_*c82 6 angularjs cordova angular-routing

我一直在撞墙,试图找出为什么angularJS路由不能在我的phonegap中工作.我已正确设置所有文件,我没有收到任何错误.我正在尝试直接从angular使用$ location.url服务更改网址.因此,当您点击div时,控制器将具有$ location.url("profile"),例如,什么都不会发生.我尝试了这个stackoverflow中找到的解决方案,但这对我不起作用.我做错了什么,或者有更好的方法来接近这个?以下是我设置的路由

var app = angular.module("App", ["hmTouchevents"])
.config(function($routeProvider) {

$routeProvider
    .when("/index.html", {
        templateUrl: "/views/login.html",
        controller: "loginCtlr"
    })
    .when("/landing", {
        templateUrl: "/views/landing.html",
        controller: "landingCtlr"
    })
    .when("/single-view/:id", {
        templateUrl: "/views/single-view.html",
        controller: "singleViewCtlr"
    })
    .when("/restaurant", {
        templateUrl: "/views/restaurant-info.html",
        controller: "restaurantCtlr"
    })
    .when("/profile/:id", {
        templateUrl: "/views/profile.html",
        controller: "profileCtlr"
    })
    .when("/lists/:list", {
        templateUrl: "/views/lists.html",
        controller: "listsCtlr"
    })
    .when("/follow/:type", {
        templateUrl: "/views/follow.html",
        controller: "followCtlr"
    });

});
Run Code Online (Sandbox Code Playgroud)

样本控制器将是:

app.controller("listsCtlr", ["$scope", "$location", function($scope, $location){

$scope.goTo("profile");

}]);
Run Code Online (Sandbox Code Playgroud)

一如往常,任何帮助都非常感谢.

lok*_*ers 0

在你的控制器中尝试...

$location.path('/profile');
Run Code Online (Sandbox Code Playgroud)