1
我的div中的一個是用ngStyle觀察背景顏色變量。任何時候我改變這個值,我會得到一個錯誤。下面請看,我覺得我有這個例子https://docs.angularjs.org/api/ng/directive/ngStylengStyle的AngularJS div背景顏色
<div class="item item-divider" ng-style="scoreColor"><b>Rate</b> {{score}}</div>
<input type="range" name="rate" min="1" max="10" value="5" step="1" ng-model="score" ng-change="changeScoreColor(score)"/>
$scope.changeScoreColor = function(score){
$scope.scoreColor = "{background-color:" + colorFromScore(score) + ";}";
};
TypeError: name.replace is not a function
at camelCase (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11098:5)
at forEach.css (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11541:12)
at Object.JQLite.(anonymous function) [as css] (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11667:9)
at http://localhost:8100/lib/ionic/js/ionic.bundle.js:33610:57
at forEach (http://localhost:8100/lib/ionic/js/ionic.bundle.js:9022:20)
at ngStyleWatchAction (http://localhost:8100/lib/ionic/js/ionic.bundle.js:33610:7)
at Object.$watchCollectionAction [as fn] (http://localhost:8100/lib/ionic/js/ionic.bundle.js:22809:13)
at Scope.$digest (http://localhost:8100/lib/ionic/js/ionic.bundle.js:22942:29)
at Scope.$apply (http://localhost:8100/lib/ionic/js/ionic.bundle.js:23205:24)
at $$debounceViewValueCommit (http://localhost:8100/lib/ionic/js/ionic.bundle.js:31961:14)
工程,太棒了!非常感謝! –