0
我只是試圖讓AngularJS表達式顯示在屏幕上。但是,大括號之間沒有任何顯示。我用ng-inspector檢查了應用程序,雖然我看到一個正在用ng-model指令創建的對象,但我無法用對象鍵顯示值。此外,出於測試目的,我甚至無法獲得簡單的數學表達式來顯示。AngularJS表達式不顯示
以下是我正在處理的內容。
<body ng-app="angularApp">
<div ng-controller="firstCtrl">
<input ng-model="project.completed" type="checkbox">
<input ng-model="project.title" type="text" placeholder="Project Title">
<label>
{{project.title}}
1+2={{1 + 2}}
</label>
<input ng-model="project.time" type="text" placeholder="Project Time">
<label for="">{{project.time}}</label>
<button ng-click="helloWorld()">Press Me</button>
</div>
</body>
...這是控制器:
angular.module('angularApp', [])
.controller('firstCtrl', function($scope) {
$scope.helloWorld = function() {
console.log('You just pressed the button.');
};
$scope.project = {
completed :false,
title :'test',
};
});
,在標籤顯示了唯一的一句話是 '1 + 2 ='。
更新:花費了大量的時間試圖調試這個後,我已經能夠獲得數學表達式的第一個值顯示 - '1'。我通過在'+'運算符周圍添加空格來實現此目的。儘管如此,完整的表達並沒有評估。
張貼您的控制器 – Sajeetharan
任何控制檯錯誤? –
你有什麼地方'ng-app =「angularApp」'? – devqon