【问题标题】:How to setup Angular example app in jsFiddle?如何在 jsFiddle 中设置 Angular 示例应用程序?
【发布时间】:2014-10-10 00:20:33
【问题描述】:

所以我正在尝试设置我的Angular app example in jsFiddle 以获取有关另一个错误的帮助,但是我遇到了一个新错误:

http://jsfiddle.net/leongaban/scx479rw/

在 Plunker 中添加示例:http://plnkr.co/edit/yYQHbcatHOu5myL4MXZM?p=preview

我无法将ng-app="portal" 添加到 html 标记,因为 jsFiddle 在输出中生成它自己的 html 标记,所以我将ng-app 放在我的第一个 div 中,这可能是问题吗?

“未捕获的错误:[$injector:nomod] 模块“门户”不可用!

HTML

 <div class="nav"
     ng-app="portal"
     ng-controller="NavController as nav">

角度

var app = angular.module('portal');

// Controller for Nav
app.controller('NavController', function() {
    ....

如果因为这个问题而找不到门户,你将如何在 jsFiddle 中设置一个 Angular 应用程序?

【问题讨论】:

  • 请阅读整个错误信息:Module 'portal' 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.
  • 我个人在 JSFiddle 中总是遇到一些问题——所以倾向于使用 plnkr.co/edit/?p=catalogue——它也会在你进行更改后立即更新,而不必按下运行。值得深思...
  • @Blackhole 很明显你可以自己看到我没有拼错“门户”再试一次......
  • 通过“整个错误消息”,我的意思是“也是最后一句话”……顺便说一下,在 JSFiddle 中使用“No wrap - in ”选项。
  • @Darren 谢谢!我现在正在尝试在这里设置我的示例应用程序:jsfiddle.net/leongaban/scx479rw 但是看起来样式不起作用

标签: javascript angularjs jsfiddle


【解决方案1】:

请看这里 http://jsfiddle.net/dvtofn6L/1/

你错过了一些 1:

var app = angular.module('portal', []);

2.

app.controller('SubNavController', function ($scope) {})
  1. 对 jquery 的引用(您可以在外部源选项卡中添加)

https://code.jquery.com/jquery-1.11.1.min.js

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-31
    • 1970-01-01
    • 2022-07-01
    • 1970-01-01
    相关资源
    最近更新 更多