簡體   English   中英

在ng上單擊其加載不同的控制器?

[英]On ng-click its loading different controller?

我正在個人資料頁面上工作,在個人資料上單擊時,我導航到profile.html頁面和profilectrl,但是當我單擊無法加載profilectrl時,我使用了$ location.path。 這是我的代碼。

這是我的點擊功能

$scope.profile=function(){
      $location.path("/profile");

    }

這是我的路由結構

sidemenu.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
    $routeProvider
        .when('/builders/:id', {
            templateUrl: '../template/listpagefilter.html',
            controller: 'buildersCtrl'
            })
        .when('/builders/:id/property/:property_id', {
            templateUrl: '../view/property-details.html',
            controller: 'unitTypeCtrl'
        })

        .when('/property/:property_id', {
            templateUrl: '../view/property-details.html',
            controller: 'unitTypeCtrl'
        })

         .when('/profile/', {      
            templateUrl: '../view/profile.html',
            controller: 'profileCtrl'
        })

}])

通過更改$ routeProvider可以工作。 代碼如下。

sidemenu.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
    $routeProvider

         .when('/profile', {        
            templateUrl: '../view/profile.html',
            controller: 'profileCtrl'
        })

        .when('/builders/:id', {
            templateUrl: '../template/listpagefilter.html',
            controller: 'buildersCtrl'
            })
        .when('/builders/:id/property/:property_id', {
            templateUrl: '../view/property-details.html',
            controller: 'unitTypeCtrl'
        })

        .when('/property/:property_id', {
            templateUrl: '../view/property-details.html',
            controller: 'unitTypeCtrl'
        })

        .when('/filterate/:query',{
            templateUrl: '../template/listpagefilter.html',
            controller: 'buildersCtrl'
        })

}])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM