Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.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
Angularjs angular js绑定和控件示例错误_Angularjs - Fatal编程技术网

Angularjs angular js绑定和控件示例错误

Angularjs angular js绑定和控件示例错误,angularjs,Angularjs,Exercise.js: var myAppModule = angular.module("myFirstModule", []); var MyAppController = function ($scope) { $scope.message = "Welcome to Angular Tutorial"; }; myAppModule.controller = ("MyAppController", MyAppController); Html文件: <!DOCTYP

Exercise.js:

var myAppModule = angular.module("myFirstModule", []);

var MyAppController = function ($scope) {
    $scope.message = "Welcome to Angular Tutorial";
};

myAppModule.controller = ("MyAppController", MyAppController);
Html文件:

<!DOCTYPE html>
<html>
<head ng-app="myFirstModule">
    <script src="Scripts/Excercise.js"></script>
    <script src="~/Scripts/angular.js"></script>
</head>
<body>
    <div ng-controller="MyAppController">
        1+5 =  {{ 1 + 5 }}
        <br />
        {{['nikhil','om','sai'] [2]}}
        <br />
        {{ {name:'nikhil',details:'om sai ' }.name }}
        <br />
        {{ message }}

    </div>
</body>
</html>

1+5 =  {{ 1 + 5 }}

{{['nikhil','om','sai'][2]}
{{{姓名:'nikhil',详细信息:'om sai'}.name}
{{message}}
当我试图解决这个问题时,我得到了一个错误。我知道这是一个小错误,但我无法找出这一点

问题很少

(i) 将控制器更改为

 myAppModule.controller('MyAppController', function ($scope) {
        $scope.message = "Welcome to Angular Tutorial";
    });
(ii)加载
angular.js
脚本,然后再加载
script.js

(iii)将ng app置于车身前方

演示

var myAppModule=angular.module(“myFirstModule”,[]);
myAppModule.controller('MyAppController',函数($scope){
$scope.message=“欢迎使用角度教程”;
});

1+5 =  {{ 1 + 5 }}

{{['nikhil','om','sai'][2]}
{{{姓名:'nikhil',详细信息:'om sai'}.name}
{{message}}
问题很少

(i) 将控制器更改为

 myAppModule.controller('MyAppController', function ($scope) {
        $scope.message = "Welcome to Angular Tutorial";
    });
(ii)加载
angular.js
脚本,然后再加载
script.js

(iii)将ng app置于车身前方

演示

var myAppModule=angular.module(“myFirstModule”,[]);
myAppModule.controller('MyAppController',函数($scope){
$scope.message=“欢迎使用角度教程”;
});

1+5 =  {{ 1 + 5 }}

{{['nikhil','om','sai'][2]}
{{{姓名:'nikhil',详细信息:'om sai'}.name}
{{message}}
将控制器更改为

myAppModule.controller('MyAppController', function ($scope) {
        // your code goes here
    });

将控制器更改为

myAppModule.controller('MyAppController', function ($scope) {
        // your code goes here
    });

除了上面@Sajeetharan的答案外,还有一个小问题是您的Exercises.js脚本可能无法加载:

<script src="Scripts/Excercise.js"></script>
<script src="~/Scripts/angular.js"></script>


缺少
~
,因此代码取决于HTML文件的位置(它将在当前目录中查找)。
angular.js
script标记不是独立的。

除了上面@Sajeetharan的答案外,还有一个小问题是您的Exercises.js脚本可能无法加载:

<script src="Scripts/Excercise.js"></script>
<script src="~/Scripts/angular.js"></script>


缺少
~
,因此代码取决于HTML文件的位置(它将在当前目录中查找)。
angular.js
script标记是不相关的。

这是我得到的输出1+5={{1+5}{{{nikhil','om','sai'][2]}{{{{name:'nikhil',details:'om sai'}.name}{{message Change
myAppModule.controller=('MyAppController',MyAppController)
myAppModule.controller(“MyAppController”,MyAppController)这是我得到的输出1+5={{{1+5}{{{nikhil','om','sai'][2]}{{{{name:'nikhil',details:'om sai'}.name}{{message}}{Change
myAppModule.controller=(“MyAppController”,MyAppController)
myAppModule.controller(“MyAppController”,MyAppController)