gpt4 book ai didi

javascript - AngularJs错误: [$injector:modulerr] Failed to instantiate module schemaForm

转载 作者:行者123 更新时间:2023-12-03 02:42:16 25 4
gpt4 key购买 nike

我正在尝试添加 angular-schema-formAngularJs Seed 。我按照 angular-schema-form 存储库中的步骤操作:

view1.js

'use strict';

angular.module('myApp.view1', ['ngRoute', 'schemaForm'])

.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/view1', {
templateUrl: 'view1/view1.html',
controller: 'FormController'
});
}])


.controller('FormController', function ($scope) {
$scope.schema = {
type: "object",
properties: {
name: {
type: "string",
minLength: 2,
title: "Name",
description: "Name or alias"
},
title: {
type: "string",
enum: ['dr', 'jr', 'sir', 'mrs', 'mr', 'NaN', 'dj']
}
}
};

$scope.form = [
"*",
{
type: "submit",
title: "Save"
}
];

$scope.model = {};
});

view1.html

<div ng-controller="FormController">
<form sf-schema="schema" sf-form="form" sf-model="model"></form>
</div>

index.html

<!DOCTYPE html>
<!--[if lt IE 7]> <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html lang="en" ng-app="myApp" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" ng-app="myApp" class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>My AngularJS App</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/normalize.css">
<link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/main.css">
<link rel="stylesheet" href="app.css">
<script src="bower_components/html5-boilerplate/dist/js/vendor/modernizr-2.8.3.min.js"></script>
</head>
<body>
<ul class="menu">
<li><a href="#!/view1">view1</a></li>
<li><a href="#!/view2">view2</a></li>
</ul>

<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->

<div ng-view></div>

<div>Angular seed app: v<span app-version></span></div>

<!-- In production use:
<script src="//ajax.googleapis.com/ajax/libs/angularjs/x.x.x/angular.min.js"></script>
-->
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="app.js"></script>
<script src="view1/view1.js"></script>
<script src="view2/view2.js"></script>
<script src="components/version/version.js"></script>
<script src="components/version/version-directive.js"></script>
<script src="components/version/interpolate-filter.js"></script>
</body>
</html>

我收到以下错误:

Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:modulerr] Failed to instantiate module myApp.view1 due to:
Error: [$injector:modulerr] Failed to instantiate module schemaForm due to:
Error: [$injector:nomod] Module 'schemaForm' 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.
http://errors.angularjs.org/1.6.8/$injector/nomod?p0=schemaForm

最佳答案

您缺少 schemaForm 的引用,需要将其添加到 app.js 上方

<script src="bower_components/angular/angular.js"></script>
<script type="text/javascript" src="bower_components/angular-schema-form/dist/schema-form.min.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="app.js"></script>

关于javascript - AngularJs错误: [$injector:modulerr] Failed to instantiate module schemaForm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48278800/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com