文章詳情頁
angular.js - angular初學者 簡單控制器的問題
瀏覽:108日期:2024-09-20 09:13:19
問題描述
視圖<!doctype html><html ng-app><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8' /><script src='angular.min.js'></script><script src='angulartest.js'></script> <style>input.ng-invalid{ background: blue;}</style></head><body ><p ng-app='myapp' ng-controller='myctrl'>{{myname}}</p></body></html>控制器var app=angular.module(’myapp’,[]);app.controller(’myctrl’,function($scope){$scope.myname='zx';});
一直都有問題 也不知道為什么 求帶
問題解答
回答1:
請把html標簽上的ng-app去掉
<html ng-app> --》<html>回答2:
1.兩個ng-app留一個;2.留下來的用ng-app='myapp';3.ng-app不要加在html上。
相關文章:
1. Span標簽2. css - 求推薦適用于vue2的框架 像bootstrap這種類型的3. docker-machine添加一個已有的docker主機問題4. css - 關于div自適應問題,大家看圖吧,說不清5. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””6. SessionNotFoundException:會話ID為null。調用quit()后使用WebDriver嗎?(硒)7. android新手一枚,android使用httclient獲取服務器端數據失敗,但是用java工程運行就可以成功獲取。8. angular.js使用$resource服務把數據存入mongodb的問題。9. java - Collections類里的swap函數,源碼為什么要新定義一個final的List型變量l指向傳入的list?10. python - django如何每次調用標簽的時候都取隨機數據
排行榜
