0
我的問題是單擊ng鍵後不會更新視圖中的{{homeCtrl.carCondition}}。從類
功能通過進口檢索AngularJS用ng-click刷新範圍對象更改值
checkVehicleCondition(brakesCondition){
let vehicle = this.brakesCondition;
if (vehicle === 0) {
this.vehicleCondition = 'Poor';
console.log(this.vehicleCondition);
} else {
this.vehicleCondition = 'Excellent';
console.log(this.vehicleCondition);
}
控制器
常量myCar =新ClientCar( 'BMW X5');
this.carCondition = myCar.vehicleCondition;// Gives object from class to the view
this.checkVehicle = myCar.checkVehicleCondition;;//Function Update vehicleCondition and should gives new value to "this.carCondition"
的index.html
<h3>Condition:{{homeCtrl.carCondition}}</h3></br>
<input type="button" value="like" ng-click="homeCtrl.checkVehicle()"></br></br>
「brakesCondition」已被分配。我的問題是不刷新carCondition $ scope值被分配(consol.log)只刷新在視圖中 –
解決方法是刪除「use strict」; idk爲什麼但它的工作 –