我是Angularjs的新手,我正试图在Ionic Framework中创建一个设置面板。我想将设置保存到localStorage,但是现在我只记录范围更改。但它没有用,而且我变得疯狂。
我的HTML
<ion-view title="Settings">
<ion-content class="has-header">
<ul class="list" ng-controller="settingsController as setting">
<ion-toggle ng-model="setting.examType.checked"
ng-change="setting.examTypeChange()"
ng-true-value="oltre"
ng-false-value="entro">
Exam Type
</ion-toggle>
</ul>
</ion-content>
</ion-view>
我的控制器是
class Settings extends Controller
constructor: ($localStorage) ->
@examType = { checked: 'entro' }
@examTypeChange = () ->
console.log('exam type change', @examType.checked)
return
我使用ng-classify,在javascript中编译,结果是:
function(){ var Settings;
Settings = (function() {
function Settings($localStorage) {
this.examType = {
checked: 'entro'
};
this.examTypeChange = function() {
console.log('exam type change', this.examType.checked);
};
}
return Settings;
}
日志不起作用:当我切换切换时没有任何事情发生。 有什么想法吗?