获取角的错误是没有定义与放大器;未捕获的错误:类型的脚本角的js无模块 [英] Getting Error of Angular is not defined & Uncaught Error:No Module in type Script Angular Js
问题描述
我实现了一个code,其中我还是坚持了这个问题。
问题1: - 未捕获的ReferenceError:角没有定义
问题2:-Uncaught错误:没有模块:CustomerSearch
我写我的code: -
和这里是我的看法页
<视图>
<%@控制语言=C#AutoEventWireup =真codeBehind =QuickSearch.ascx.cs继承=CustomerSearch.QuickSearch1%GT;
<!DOCTYPE HTML>
<%@注册标签preFIX =DNN命名空间=DotNetNuke.Web.Client.ClientResourceManagement大会=DotNetNuke.Web.Client%GT; < HTML和GT;
<头ID =头像1>
&所述; SCRIPT SRC =HTTP://$c$c.jquery.com/jquery-latest.js>&下; /脚本>
&所述; SCRIPT SRC =https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js>&下; /脚本>
<脚本类型=文/ JavaScript的SRC =https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js>< / SCRIPT>
< DNN:DnnJsInclude =服务器文件路径=〜/门户/ _default / Customer.Search /位指示/ QuickSearchController.js/>
< DNN:DnnJsInclude =服务器文件路径=〜/门户/ _default / Customer.Search /接口/ module.js/>
<% - < DNN:DnnJsInclude =服务器文件路径=〜/门户/ _default / Customer.Search / app.routes.js/> - %GT; <标题>< /标题>
<脚本类型=文/ JavaScript的> < / SCRIPT>
< /头>
<机身NG-应用=CustomerSearch>
<表ID =form1的>
< DIV> < DIV ID =页面NG控制器=CustomerCtrl定制> < DIV ID =menuleftcontent>
<表>
&所述; TR的id =菜单>
< TD WIDTH =25px的重要;!><输入类型=文本ID =txtActId值=搜索级=tftextinput2NG模型=search.txtActId/> < / TD>
< TD><输入类型=按钮值=搜索级=tfbutton2数据-NG-点击=搜索(搜索)/> < / TD> < / TR>
&所述; TR的id =TableRow1>
&所述; TD列跨度=2>
< ASP:DropDownList的ID =listCustomerType=服务器的CssClass =下拉菜单WIDTH =194pxHEIGHT =27pxNG模型=search.listCustomerType> < / ASP:DropDownList的>
< / TD>
< / TR>
&所述; TR>
&所述; TD列跨度=2>
<输入类型=复选框ID =checkActiveOnly级=NormalTextBoxVALUE =活动客户只NG模型=search.checkActiveOnly/>活动客户只
< BR>
<输入类型=复选框ID =checkParentsOnly级=NormalTextBoxVALUE =父帐户只有NG模型=search.checkParentsOnly/>家长仅占
< / TD>
< / TR>
< /表> < DIV> < DIV>
< DIV>
要重现这种问题,我们既可以
1)删除棱角脚本引用,或结果
2)只是将其放置在非常迟到的位置,我们的模块了。
有破plunker 这为我们提供了这样的错误:
未捕获的ReferenceError:角没有定义
块引用>由于我们跳过角脚本
<! - <脚本数据需要=angular.js@*
SRC =https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.0/angular.js
>&下; /脚本&GT - →;&所述; SCRIPT SRC =MainApp.js>&下; /脚本>
&所述; SCRIPT SRC =CustomerSearch.dirc.js>&下; /脚本>同样的问题的(与许多其他错误)的我们面前,如果我们把的角的页面太晚的(我们的模块定义后)。勾选此破例如
未捕获的ReferenceError:角未定义(匿名函数)@ MainApp.js:1
未捕获的错误:[$喷油器:NOMOD]模块'CustomerSearch不可!你要么拼写错误的模块名称,或忘了加载它。如果注册一个模块,确保指定的依赖关系作为第二个参数。
块引用>这行是罪魁祸首:
<脚本SRC =MainApp.js>< / SCRIPT><脚本数据需要=angular.js@*
SRC =https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.0/angular.js
>< / SCRIPT>&所述; SCRIPT SRC =CustomerSearch.dirc.js>&下; /脚本>在的情况下,所有的正确页面下令,它会工作(这是 WORKING plunker ):
<脚本数据需要=angular.js@*
SRC =https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.0/angular.js
>< / SCRIPT>
&所述; SCRIPT SRC =MainApp.js>&下; /脚本>
&所述; SCRIPT SRC =CustomerSearch.dirc.js>&下; /脚本>这些是那种错误的...
标准问题此外,在情况下,我们得到
未捕获的错误:[$喷油器:NOMOD]模块'CustomerSearch不可!你要么拼写错误的模块名称,或忘了加载它。如果注册一个模块,确保指定的依赖关系作为第二个参数。
块引用>这可以通过我们的自己的脚本错误的位置引起:在
<脚本数据需要=angular.js@*
SRC =https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.0/angular.js
>< / SCRIPT>&所述; SCRIPT SRC =CustomerSearch.dirc.js>&下; /脚本>
&所述; SCRIPT SRC =MainApp.js>&下; /脚本> //这个应该是在另一个之前由于MainApp.js定义模块:
VAR应用= angular.module('MainApp',[
CustomerSearch
]);angular.module('CustomerSearch',[])而CustomerSearch.dric.js使用它们
VAR应用= angular.module('CustomerSearch');
因此,我们需要声明发生第一个
扩展
从这个问题code片断:
< HTML和GT;
<头ID =头像1>
< DNN:DnnJsInclude =服务器文件路径=〜/门户/ _default / Customer.Search /应用/位指示/ QuickSearchController.js/>
< DNN:DnnJsInclude =服务器文件路径=〜/门户/ _default / Customer.Search /应用/接口/ Interface.js/>
< DNN:DnnJsInclude =服务器文件路径=〜/门户/ _default / Customer.Search /脚本/ angular.js/>
< DNN:DnnJsInclude =服务器文件路径=〜/门户/ _default / Customer.Search /脚本/ angular.min.js/>
< DNN:DnnJsInclude =服务器文件路径=〜/门户/ _default / Customer.Search /应用/ app.routes.js/>
< DNN:DnnJsInclude =服务器文件路径=〜/门户/ _default / Customer.Search /应用/ app.module.js/>
&所述; SCRIPT SRC =HTTP://$c$c.jquery.com/jquery-latest.js>&下; /脚本>
&所述; SCRIPT SRC =https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js>&下; /脚本>应该是(我猜)重组:
< HTML和GT;
<头ID =头像1>
//这必须是第一
&所述; SCRIPT SRC =HTTP://$c$c.jquery.com/jquery-latest.js>&下; /脚本>
&所述; SCRIPT SRC =https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js>&下; /脚本> //模块必须首先定义
< DNN:DnnJsInclude =服务器文件路径=〜/门户/ _default / Customer.Search /应用/ app.module.js/>
//剩下的最有可能的可能是因为是
< DNN:DnnJsInclude =服务器文件路径=〜/门户/ _default / Customer.Search /应用/位指示/ QuickSearchController.js/>
< DNN:DnnJsInclude =服务器文件路径=〜/门户/ _default / Customer.Search /应用/接口/ Interface.js/>
< DNN:DnnJsInclude =服务器文件路径=〜/门户/ _default / Customer.Search /脚本/ angular.js/>
< DNN:DnnJsInclude =服务器文件路径=〜/门户/ _default / Customer.Search /脚本/ angular.min.js/>
< DNN:DnnJsInclude =服务器文件路径=〜/门户/ _default / Customer.Search /应用/ app.routes.js/>I have implemented a code where i stuck with this problem. Problem 1:- Uncaught ReferenceError: angular is not defined Problem 2:-Uncaught Error: No module: CustomerSearch
I have written my code:-
and here is my view page
<view> <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="QuickSearch.ascx.cs" Inherits="CustomerSearch.QuickSearch1" %> <!DOCTYPE html> <%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.Client.ClientResourceManagement" Assembly="DotNetNuke.Web.Client" %> <html > <head id="Head1" > <script src ="http://code.jquery.com/jquery-latest.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> <dnn:DnnJsInclude runat="server" FilePath="~/Portals/_default/Customer.Search/Contoller/QuickSearchController.js" /> <dnn:DnnJsInclude runat="server" FilePath="~/Portals/_default/Customer.Search/Interface/module.js" /> <%-- <dnn:DnnJsInclude runat="server" FilePath="~/Portals/_default/Customer.Search/app.routes.js" />--%> <title></title> <script type="text/javascript"> </script> </head> <body ng-app="CustomerSearch"> <form id="form1" > <div> <div id="page" ng-controller="CustomerCtrl as custom"> <div id="menuleftcontent"> <table> <tr id="menu"> <td width="25px !important;"><input type="text" id="txtActId" value="Search" class="tftextinput2" ng-model="search.txtActId" /> </td> <td><input type="button" value="Search" class="tfbutton2" data-ng-click="search(search)" /> </td> </tr> <tr id="TableRow1"> <td colspan="2"> <asp:DropDownList ID="listCustomerType" runat="server" CssClass="dropdown" Width="194px" Height="27px" ng-model="search.listCustomerType"> </asp:DropDownList> </td> </tr> <tr> <td colspan="2"> <input type="checkbox" id="checkActiveOnly" class="NormalTextBox" value="Active Customers Only" ng-model="search.checkActiveOnly" />Active Customers Only <br> <input type="checkbox" id="checkParentsOnly" class="NormalTextBox" value="Parent Accounts Only" ng-model="search.checkParentsOnly" />Parent Accounts Only </td> </tr> </table> <div > <div> <div>
解决方案To reproduce this kind of issue, we can either
1) "remove" angular script reference, or
2) just place it at the very "late" position, after our modules.There is a broken plunker which will provide us with this error:
Uncaught ReferenceError: angular is not defined
because we skipped angular script
<!--<script data-require="angular.js@*" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.0/angular.js" ></script>--> <script src="MainApp.js"></script> <script src="CustomerSearch.dirc.js"></script>
The same issue (with many other errors) we would face, if we place angular in the page too late (after our module definition). Check this broken example
Uncaught ReferenceError: angular is not defined(anonymous function) @ MainApp.js:1 Uncaught Error: [$injector:nomod] Module 'CustomerSearch' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
This lines were the culprit:
<script src="MainApp.js"></script> <script data-require="angular.js@*" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.0/angular.js" ></script> <script src="CustomerSearch.dirc.js"></script>
In case, that all is properly ordered in page, it will work (this is WORKING plunker):
<script data-require="angular.js@*" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.0/angular.js" ></script> <script src="MainApp.js"></script> <script src="CustomerSearch.dirc.js"></script>
These are standard issues with that kind of error...
Also, in case we get
Uncaught Error: [$injector:nomod] Module 'CustomerSearch' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
That could be caused by wrong placement of our own scripts:
<script data-require="angular.js@*" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.0/angular.js" ></script> <script src="CustomerSearch.dirc.js"></script> <script src="MainApp.js"></script> // this one should be before the other one
because MainApp.js defines modules:
var app = angular.module('MainApp', [ 'CustomerSearch' ]); angular.module('CustomerSearch',[])
And the CustomerSearch.dric.js uses them
var app = angular.module('CustomerSearch');
so, we need the declaration to happen first
EXTEND:
This code snippet from the question:
<html > <head id="Head1" > <dnn:DnnJsInclude runat="server" FilePath="~/Portals/_default/Customer.Search/app/Contoller/QuickSearchController.js" /> <dnn:DnnJsInclude runat="server" FilePath="~/Portals/_default/Customer.Search/app/Interface/Interface.js" /> <dnn:DnnJsInclude runat="server" FilePath="~/Portals/_default/Customer.Search/Scripts/angular.js" /> <dnn:DnnJsInclude runat="server" FilePath="~/Portals/_default/Customer.Search/Scripts/angular.min.js" /> <dnn:DnnJsInclude runat="server" FilePath="~/Portals/_default/Customer.Search/app/app.routes.js" /> <dnn:DnnJsInclude runat="server" FilePath="~/Portals/_default/Customer.Search/app/app.module.js" /> <script src ="http://code.jquery.com/jquery-latest.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
Should be (I guess) reorganized:
<html > <head id="Head1" > // THIS MUST be first <script src ="http://code.jquery.com/jquery-latest.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script> // MODULES must be defined first <dnn:DnnJsInclude runat="server" FilePath="~/Portals/_default/Customer.Search/app/app.module.js" /> // the rest most likely could be as is <dnn:DnnJsInclude runat="server" FilePath="~/Portals/_default/Customer.Search/app/Contoller/QuickSearchController.js" /> <dnn:DnnJsInclude runat="server" FilePath="~/Portals/_default/Customer.Search/app/Interface/Interface.js" /> <dnn:DnnJsInclude runat="server" FilePath="~/Portals/_default/Customer.Search/Scripts/angular.js" /> <dnn:DnnJsInclude runat="server" FilePath="~/Portals/_default/Customer.Search/Scripts/angular.min.js" /> <dnn:DnnJsInclude runat="server" FilePath="~/Portals/_default/Customer.Search/app/app.routes.js" />
这篇关于获取角的错误是没有定义与放大器;未捕获的错误:类型的脚本角的js无模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!