在我的index.html
文件中,我創建了一個非常簡單的表單。我已經將大部分細節分解爲app.js
,這樣如果有人想讓他們的表單版本看起來不同,他們只需插入app.js
的修改副本(試圖在此處進行移植)。從AngularJS插入文本到
但是,我對AngularJS很新,這是很多app.js
正在使用的。我可以請一些幫助!
這裏是我遇到一些麻煩的代碼片段:
<body ng-controller="controller">
<div class="page">
<section class="signin">
<form name="form" novalidate>
<div class="intro">
<label ng-model="service-desk-name"></label>
<span ng-bind="service-desk-name"></span>
<label ng-model="welcome"></label>
<span ng-bind="welcome"></span>
</div>
加上:
var app = angular.module('app',[]);
app.controller('controller', ['$scope', function($scope) {
$scope.service-desk-name = 'Arbitrary Service Desk Name';
$scope.welcome =
'Please sign in and a consultant will be with you shortly.';
}]);
因爲我可以做一些極不正常,我會解釋一下我想做。 intro
部分顯示在實際表單上方,分別顯示服務檯名稱以及通過ng-model="service-desk-name"
和ng-model="welcome"
的某種自定義歡迎或信息性消息。我的希望是我可以通過HTML獲取我在app.js
中定義的這兩個模型的值。這樣,HTML不會控制顯示的內容,它只是抓住定義的內容並顯示它。
現在,這些字段根本沒有顯示在網頁上,這表明這只是某種語法錯誤。我對Angular很陌生,所以我不知道該從哪裏嘗試修復它。
現在你已經明白了這個區別。這工作!我只需將'service-desk-name'變量改爲'servicedeskkiosk'來修正語法錯誤。 – UnworthyToast
是真的,沒注意到! – Ozrix