app.config(['$routeProvider', function($routeProvider){
$routeProvider.when('/', {
templateUrl: tplPath + '/posts.html',
controller: 'mctrl'
});
}]);
app.controller('mctrl', ['$scope', '$http', '$log', handleMctrl]);
function handleMctrl($scope, $http, $log) {
var self = this;
console.log(self);
var resp = $http.get('/post/new');
resp.success(function (data, status, headers, config) {
$log.debug(data);
self.data = data;
});
};
会请求 /pot/new 两次
You mean:
Printed twice?
That’s probably because you referenced mctrl again on the page. Try removing ng-controller="mctrl"