gpt4 book ai didi

javascript - 如何在angular js中动态生成表单?

转载 作者:行者123 更新时间:2023-11-29 18:13:26 25 4
gpt4 key购买 nike

我正在使用这个 https://github.com/Textalk/angular-schema-form生成我的表单的插件不会显示。我研究了所有文档并添加了所有需要的 js 我没有收到任何错误但它不显示为什么? http://plnkr.co/edit/FO5iEs6ulmP3aR0PW4nt?p=preview

<!DOCTYPE html>
<html >

<head>
<link data-require="bootstrap-css@3.x" data-semver="3.2.0" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />
<script data-require="angular.js@*" data-semver="1.3.0-beta.5" src="https://code.angularjs.org/1.3.0-beta.5/angular.js"></script>
<script data-require="ui-bootstrap@0.10.0" data-semver="0.10.0" src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.10.0.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
<script src="https://dl.dropboxusercontent.com/s/8fq4c4t7jct4w4h/schema-form.js?m="></script>
<script src="https://dl.dropboxusercontent.com/s/unk0id7tmc9w0mm/angular-sanitize.js?m="></script>
<script src="https://dl.dropboxusercontent.com/s/icrciconaesuw29/tv4.js?m="></script>
<script src="https://dl.dropboxusercontent.com/s/rk0dfetihiqs7bi/ObjectPath.js"></script>




</head>

<body>
<div ng-controller="FormController">
<form sf-schema="schema" sf-form="form" sf-model="model"></form>
</div>
<script>
function FormController($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 = {};
}
</script>
</body>

</html>

最佳答案

问题是包含的 javascript 插件顺序不正确。

同样使用angular.module()来初始化 Controller 。

JS:

    angular.module('test',['schemaForm']).controller('FormController', function($scope,$http){
$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 = {};
})

Demo

关于javascript - 如何在angular js中动态生成表单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25321306/

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