我正在使用 angularJS1.2 路由功能来部分加载一些视图。
var app = angular.module('app', ['ngAnimate', 'ngRoute']).config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$routeProvider.when('/profile/personalInfo', {templateUrl: '<?php echo base_url().'profile/personalInfo' ?>', controller: personalInfo});
$routeProvider.when('/profile/myPlaces', {templateUrl: '<?php echo base_url().'profile/myPlaces' ?>', controller: myPlaces});
$routeProvider.otherwise({redirectTo: '/profile/personalInfo'});
$locationProvider.html5Mode(true);
}]);
function personalInfo($scope, $http){
console.log('personal info');
}
function myPlaces($scope, $http){
console.log('my places');
$scope.places = [];
//then fill places via $http.post request
$scope.loadMore = function(){
console.log('clicked');
}
}
这是我的平页:
<div>
<h1>My Places Page</h1>
<div ng-repeat="place in places">
<a href="" ng-click="loadMore()">load more</a>
</div>
</div>
路由已成功完成,但是当我单击链接调用loadMore
时,控制台中出现此错误undefined is not a function
。有什么问题,我该如何解决?