angular.js - angular初學(xué)者 簡(jiǎn)單控制器的問題
問題描述
視圖<!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:
請(qǐng)把html標(biāo)簽上的ng-app去掉
<html ng-app> --》<html>回答2:
1.兩個(gè)ng-app留一個(gè);2.留下來的用ng-app='myapp';3.ng-app不要加在html上。
相關(guān)文章:
1. javascript - main head .intro-text{width:40%} main head{display:flex}為何無效?2. Python中使用超長(zhǎng)的List導(dǎo)致內(nèi)存占用過大3. javascript - 有適合開發(fā)手機(jī)端Html5網(wǎng)頁(yè)小游戲的前端框架嗎?4. javascript - axios請(qǐng)求回來的數(shù)據(jù)組件無法進(jìn)行綁定渲染5. java - 在用戶不登錄的情況下,用戶如何添加保存到購(gòu)物車?6. 安全性測(cè)試 - nodejs中如何防m(xù)ySQL注入7. javascript - JS變量被清空8. javascript - 關(guān)于apply()與call()的問題9. java - spring boot 如何打包成asp.net core 那種獨(dú)立應(yīng)用?10. css3 - 純css實(shí)現(xiàn)點(diǎn)擊特效
