文章詳情頁
angular.js - angular初學者 簡單控制器的問題
瀏覽:78日期: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. 輸入地址報以下截圖錯誤,怎么辦?2. angular.js - angularJs ngRoute怎么在路由傳遞空字符串及用ng-switch取得3. javascript - ie11以下單擊打開不了file,雙擊可以。求解?4. vim里的高亮javascript的javascript.vim 已經放到syntax里了,但是不行。5. html5 - video ios不能播放怎么辦?6. android - xml的drawable作背景,是否會產生錯誤7. python - pip install出現下面圖中的報錯 什么原因?8. node.js - node中MYSQL的異步問題9. javascript - 求助一個關于indexedDB的問題10. 我何時應該在Java中使用JFrame.add(component)和JFrame.getContentPane()。add(component)
排行榜
