为什么我简单的角度示例不能在小提琴上工作

Why my simple angular example can not work on fiddle?

本文关键字:不能 小提琴 工作 简单 为什么      更新时间:2023-09-26

HTML:

<body ng-app="myApp" ng-controller="myCtrl">
<input ng-model="msg" />
<p my-dctv >
    {{msg | myUpperFilter }}
</p>

// the main (app) module
var myApp = angular.module("myApp", []);
// add a controller`enter code here`
myApp.controller("myCtrl", function($scope) {
    $scope.msg = "hello world";
});
// add a filter
myApp.filter("myUpperFilter", function() {
    return function(input) {
        return input.toUpperCase();
    }
});
// add a directive
myApp.directive("myDctv", function() {
    return function(scope, element, attrs) {
        element.bind("mouseenter", function() {
            element.css("background", "yellow");
        });            
        element.bind("mouseleave", function() {
            element.css("background", "none");
        });            
    }
});

错误消息:无模块:我的应用

这是我的小提琴工作块在此处输入链接说明

我只是从在此处输入链接说明

外部资源也复制了。

你已经完美地完成了所有工作,除了包括angularjs文件。虽然,您已将其添加为外部文件,但建议从 jsFiddle 本身的可用列表中包含。

javascript 部分的右上角,有一个设置图标,单击它时,它会打开一个弹出窗口,要求一些东西。

在其中选择以下内容 -:

  1. 语言> Javascript
  2. 框架和扩展> AngularJS 1.2.1(或任何其他版本)
  3. 负载类型> 无包装 - 在头中
  4. 框架脚本属性>(不更改)

通过这种方式,您将能够看到在jsFiddle中运行的代码。

供您参考,我已将您的代码分叉成一个新代码。

请参考演示。