简体   繁体   English

AngularJS控制器没有在jsFiddle中执行

[英]AngularJS controller not executing in jsFiddle

I was trying to learn the most basic implementation of controllers and modules in AngularJS. 我试图学习AngularJS中控制器和模块的最基本实现。

Here is the code I have tried: 这是我尝试过的代码:

 var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.firstName= "John"; $scope.lastName= "Doe"; }); 
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="myApp" ng-controller="myCtrl"> <h1> This is the most <a href='http://www.w3schools.com/angular/tryit.asp?filename=try_ng_intro_controller'>basic angularJS controller</a> implementation </h1> First Name: <input type="text" ng-model="firstName"><br> Last Name: <input type="text" ng-model="lastName"><br> <br> Full Name: {{ firstName + " " + lastName }} </div> 

The output is not getting updated: 输出未更新:

产量

You need to select No wrap - in <body> in the dropdown menu in Frameworks and extensions tab, check the pic: 你需要在框架和扩展选项卡的下拉菜单中选择No wrap - in <body> ,检查图片:

在此输入图像描述

Updated JSFiddle 更新了JSFiddle

Just a small issue, 只是一个小问题,

Angularjs script did not get referenced. Angularjs脚本没有被引用。 Just change it to wrap it in head, 只需改变它就可以将它包裹起来,

Here is the working JsFiddle 这是工作的JsFiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM