請注意,此問題的標題已更改爲更專注於確切問題的標題。見註釋流跟蹤是怎麼回事,我才意識到問題是AngularJS似乎並沒有處理{{isNaN()}}爲什麼{{isNan(x)}}在angularJS中不起作用?
我有以下的在我的HTML:
xx {{ option.selectedSubject }} yy {{ (option.selectedSubject == null) }} zz
和我也試過:
xx {{ option.selectedSubject }} yy {{ option.selectedSubject == null }} z
和:
xx {{ option.selectedSubject }} yy {{ option.selectedSubject === null }} zz
有人可以幫助解釋給我,爲什麼我得到的以下爲每一個上面時,我認爲我的網頁:
xx null yy false zz
更新1我試過如下:
aa {{ option.selectedSubject === "null" }} bb {{ option.selectedSubject == "null" }} cc
,並讓這樣的:
aa false bb false cc
更新2我不確定這是否有幫助,但是這是什麼填充option.selectedSubject的值。在這種情況下,沒有什麼在本地存儲:
$scope.option.selectedSubject = parseInt(localStorage.get('selectedSubject'));
當我檢查$ scope.option.selectedSubject的價值是NaN的
你希望看到什麼? –
xx null yy true zz –
任何你將'option.selectedSubject'設置爲「null」而不是'null'的機會?檢出:http://jsfiddle.net/y3xzB/1/ – KayakDave