我有两个控制器profileCtrl和todayCtrl,我在todayctrl中使用ui-router。我的today.js页面就像这样
var app = angular.module("Today",['ui.router]);
app.config(function($stateProvider, $urlRouterProvider) {
// For any unmatched url, redirect to /state1
$urlRouterProvider.otherwise("");
//
// Now set up the states
$stateProvider
.state('profile', {
url: "/?id",
templateUrl: 'profile.html',
controller: function($scope,$stateParams,$http) {
var user_id = $stateParams.id;
$http.get('index.php?r=profile/user-profile&user_id='+user_id
//this is where my data will come from my php controller and i have data here.
).success(function(data){
$scope.profile = data;
});
}
})
});
app.controller("TodayCtrl",function($scope,$http){
//some
});
但我的templateUrl是视图页面的链接
<div ng-app="" ng-controller="profileCtrl">
{{profile}}
<div>
如果我把ng-controller作为todayCtrl我得到数据。但我需要的是profileCtrl。 有人可以建议我如何使用profileCtrl,因为我在profileCtrl中有其他控制器功能。