搜索

首页  >  问答  >  正文

angular.js - angular初学者 简单控制器的问题

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

<code>视图

<!doctype html>

<html ng-app>

    <head>

       <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

        <script src="angularJs/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";

});

</code>

一直都有问题 也不知道为什么 求带

大家讲道理大家讲道理2829 天前499

全部回复(2)我来回复

  • 伊谢尔伦

    伊谢尔伦2017-05-15 17:13:15

    请把html标签上的ng-app去掉

    1

    <code><html ng-app>  --》  <html></code>

    回复
    0
  • 阿神

    阿神2017-05-15 17:13:15

    1.两个ng-app留一个;
    2.留下来的用ng-app="myapp";
    3.ng-app不要加在html上。

    回复
    0
  • 取消回复