[英]AngularJS .value(): not getting the Updated/Modified value in Controller
[英]AngularJS, View is not getting updated on change in Modal value from controller
嘗試從控制器更改模態值時,未更新View(question_to_vote)。
查看文件:question_to_vote.html
<div class="alert alert-success text-center" ng-show="c.message.success">
<strong>Success!</strong> Question Posted
</div>
<button ng-click="c.insert_public_q()"> Active </button>
控制器:
app.controller("ques_controller",function($http,$state,$interval,$mdBottomSheet,$timeout){
let vm = this;
vm.message = {success:true};
vm.message.success = false;
vm.insert_public_q = function(){
var upvote = {vote:1,name:"Mahesh"};
$http({method:"post",url:"insert-top-downvote",data:{upvote:upvote}}).success(function(result){
vm.message.success = true;
});
})
});
路線
var app = angular.module("around_a",['ui.router','ngMaterial']);
app.config(function($interpolateProvider,$stateProvider,$urlRouterProvider){
$interpolateProvider.startSymbol('[[').endSymbol(']]');
$urlRouterProvider.otherwise('/home');
$stateProvider
.state('add_ques.questions_to_vote',{
url: '/questions-to-vote',
templateUrl:'questions_to_vote.html',
controller:'ques_controller as c'
});
});
<div class="alert alert-success text-center" ng-show="message.success">
<strong>Success!</strong> Question Posted
</div>
<button ng-click="c.insert_public_q()"> Active </button>
沒有c.message.success
它的message.success
哦,是的另一件事
app.controller("ques_controller",function($http,$state,$interval,$mdBottomSheet,$timeout,$scope){
$scope.message = {success:true};
$scope.message.success = false;
$scope.insert_public_q = function(){
var upvote = {vote:1,name:"Mahesh"};
$http({method:"post",url:"insert-top-downvote",data: {upvote:upvote}}).success(function(result){
$scope.message.success = true;
});
})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.