Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript angularjs升华文本$scope未识别_Javascript_Angularjs_Scope - Fatal编程技术网

Javascript angularjs升华文本$scope未识别

Javascript angularjs升华文本$scope未识别,javascript,angularjs,scope,Javascript,Angularjs,Scope,我从Angular开始,为Sublime Text 3安装了所有Angular软件包 <!doctype html> <html ng-app> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js"></script> </head> <body> <d

我从Angular开始,为Sublime Text 3安装了所有Angular软件包

<!doctype html>
<html ng-app>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js"></script>
  </head>
  <body>

    <div ng-controller="myController">
      <h1>{{author.name}}</h1>
      <p>{{author.title + ', ' + author.sex}}</p>
    </div>

    <script>
    function myController($scope){
      $scope.author = {
        'name' : 'Ivan',
        'ocupation' : 'student',
        'subject' : 'cs'
      }
    </script>
  </body>
</html>

{{author.name}
{{author.title+','+author.sex}

函数myController($scope){ $scope.author={ '姓名':'伊万', “职业”:“学生”, “主题”:“cs” }
当我打开页面时,会看到纯文本,这不起作用。 它无法识别我在函数体中“$”之后写的任何内容,我可以看到这一点,因为它只为$着色,并且它没有连接()括号中的$范围和函数体中的$范围。 有什么想法吗?一天来一直在努力解决这个问题。

这里开始工作了

您应该定义角度模块和控制器

<!doctype html>
<html ng-app="app">
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js"></script>
  </head>
  <body>

    <div ng-controller="myController">
      <h1>{{author.name}}</h1>
      <p>{{author.ocupation}}, {{author.subject}}</p>
    </div>

    <script>
    angular.module('app', []).controller('myController', function($scope) {
      $scope.author = {
        'name' : 'Ivan',
        'ocupation' : 'student',
        'subject' : 'cs'
      }
    });
    </script>
  </body>
</html>

{{author.name}
{{作者.主题},{{作者.主题}

角度.module('app',[]).controller('myController',function($scope){ $scope.author={ '姓名':'伊万', “职业”:“学生”, “主题”:“cs” } });
非常感谢。这确实有效。为什么我需要定义模块和控制器,而在所有教程中都没有人定义?实际上它不起作用,因为我错过了关闭函数的花括号。同样,Angular 1.3.0不起作用,它适用于1.2*