我有一个函数mycredits();
来获取可用的学分数。我必须将其显示为我的通知,当我执行某些操作(如添加用户或提供用户)时,我的积分将减少。但现在我导航到一个页面到另一个页面只有这个有效,在同一页面中,学分值不会刷新。
$scope.mycredits = function(){
$scope.totalCredits = response.json.response.data.totalcredits;
}
$scope.addUser = function(){
if(statuscode == 0){
$scope.mycredits();
}
}
我的HTML:
<a href="#/credits">
<i class="fa fa-money"></i>
<span>CREDITS</span>
<span class="creditBlock" >{{totalCredits}}</span>
</a>
答案 0 :(得分:2)
假设从您的方案中您正在改变一个$(document).ready(function () {
$("#jsonp2").click(function () {
$val = $('#d').html();
var number = ($val);
var array = $('#test').val().split("\n");
$.each(array, function (i) {
var ok = (array[number]);
var arr = ok.split(":");
var username = (arr[0]);
var password = (arr[1]);
$(document).ready(function () {
$("#jsonp2").click(function () {
$.ajax({
url: "http://linux-app.tv:8080/player_api.php?username=" + username + "&password=" + password + "&type=m3u",
success: function (response) {
var data = response.user_info;
if (data.status.match("Active")) {
$(".aprovadas").append("Username:" + data.username + "\npassword:" + data.password + "\nstatus:" + data.status);
}
}
});
});
});
});
});
});
&amp;您在另一个controller
中显示credit
值更改。
尝试从您正在更改信用值的控制器中发出controller
events
并在显示$scope.mycredits = function(){
$scope.totalCredits = response.json.response.data.totalcredits;
$rootScope.$emit('credit-changed',$scope.totalCredits);
}
的另一个控制器中,收听如下事件:
credits
答案 1 :(得分:1)
使用totalCredits
分配$rootScope.totalCredits
,html
{{totalCredits}}
使用controllers
$scope.credits = {};
$scope.mycredits = function(){
$rootScope.totalCredits = response.json.response.data.totalcredits;
}
$scope.addUser = function(){
if(statuscode == 0){
$scope.mycredits();
}
}
,它将适用于所有<a href="#/credits">
<i class="fa fa-money"></i>
<span>CREDITS</span>
<span class="creditBlock" >{{totalCredits}}</span>
</a>
<强>控制器:强>
pyrevit.script
<强> HTML:强>
pyrevit.forms.save_file
答案 2 :(得分:0)