0
我希望我的視圖在我的服務中將新值傳遞給控制器時進行更新。AngularJS - 更新服務數據更改視圖
service.js
function navigationTreeService($http, $q, perspectivesService) {
return {
getExtension: getExtension
};
function getExtension(){
return extension;
}
function setExtension(value){
extension = value;
}
//
}
controller.ts
angular.module('myModule').controller('ViewController',
['$scope', '$rootScope', 'userSessionService', 'navigationTreeService', '$http',
function ($scope, $rootScope, userSessionService, navigationTreeService, $http) {
'use strict';
$scope.extensionNavi = navigationTreeService.getExtension();
}]);
view.html
<div class="extensionNavi" style="height: 50px; width: 400px;">
{{extensionNavi}}
</div>
下面的代碼只有一次更新的觀點,我希望它被更新一次時間爲service.js中的擴展設置了一個新值。我怎樣才能做到這一點? 在此先感謝。