index.html
<div class="modal-body">
<form >
<tags options="{addable: true}" typeahead-options="typeaheadOpts" data-model="information.address" data-src="toPerson as toPerson for toPerson in to"></tags>
<input type="text" placeholder="Subject" style="width:95%;" data-ng-model = "information.subject"><br />
<textarea style="width:95%;" rows="10" data-ng-model = "information.emailContent"></textarea>
</form>
</div>
<div class="modal-footer">
<a href="#" class="btn" ng-click = "submit(information.address, information.subject, information.emailContent); close()">Close</a>
<a href="#" class="btn btn-primary" ng-click = "close()">Send</a>
</div>
emailViewController.js
$scope.information = {
address: [],
subject: []
};
$scope.submit = function (address, subject, emailContent) {
$localStorage.address.push(address);
if (! ($localStorage.subject instanceof Array) ) {
$localStorage.subject = [];
}
$localStorage.subject.push(subject);
$localStorage.subject
配列として初期化しないと、というエラーが表示されます.push is not a function
。
にデータをプッシュしてもこのエラーが発生しないのはなぜ$localStorage.address
ですか?