我要刷新AngularJS中的元素,但以下代码隐藏了整个ng-view内容
var firstModule = angular.module('myModule', ['ngRoute', 'ngAnimate']);
var mainDataServiceInjectParams = ['$http', '$q'];
var mainFactory = function ($http, $q) {
var mainDataService = {};
mainDataService.refreshStatus = function (id) {
return $http.get('/api/values/' + id).then(function (results) {
return results.data;
});
};
return mainDataService;
};
mainFactory.$inject = mainDataServiceInjectParams;
firstModule.factory('mainService', mainFactory);
firstModule.controller('myCtrl', function ($scope, $http, mainService) {
$scope.TST = {};
$scope.clickMe = function (id) {
$scope.loading = true;
mainService.refreshStatus(id).then(function (results) {
$scope.TST = 'abc';
$scope.loading = false;
});
}
});
firstModule.config(function ($routeProvider) {
$routeProvider.when("/status/:id", {
templateUrl: 't.html',
controller: 'myCtrl'
});
});
t.html
<a class="btn btn-primary btn-mini" href="#" ng-click="clickMe(321)">Refresh</a>
{{TST}}
点击t.html
链接后,整个Refresh
内容消失了。为什么?
我只需从href="#"
<a>
内的t.html