我试图懒惰地配置自定义类型的angular-formly
withocLazyLoad
但我不能。执行时state
,我试图调用该setType
函数,但此后页面未加载任何内容。当我删除该setType
功能时,一切正常。有什么方法可以懒惰地配置formly
类型吗?
formlyConfig.setType({
name: 'input',
template: '<input ng-model="model[options.key]" />'
});
粗略地说,这是一个例子:
//ocLazyLoad Configurations
$ocLazyLoadProvider.config({
events: true,
debug: true,
modules: [
{
name: "formly",
files: [ "Scripts/formly/angular-formly.js" ]
},
{
name: "formlyBootstrap",
files: [ "Scripts/formly/angular-formly-templates-bootstrap.js" ]
}
]
});
//Ui-Router Configs
$stateProvider
.state("admin", {
abstract: true,
url: "/admin",
templateUrl: "App/admin/templates/content.html",
resolve: {
loadApiCheck: ["$ocLazyLoad", function ($ocLazyLoad) {
return $ocLazyLoad.load("Scripts/formly/api-check.js");
}],
loadFormly: ["loadApiCheck", "$ocLazyLoad", function (loadApiCheck, $ocLazyLoad) {
return $ocLazyLoad.load("formly");
}],
loadFormlyBootstrap: ["loadFormly", "formlyConfig", "$ocLazyLoad", function (loadFormly, formlyConfig, $ocLazyLoad) {
//* * *
//After formlyConfig.setType() nothing gets executed
//* * *
debugger;
formlyConfig.setType({
name: 'input',
template: '<input ng-model="model[options.key]" />'
});
return $ocLazyLoad.load("formlyBootstrap");
}]
}
})
.state("admin.contact", {
url: "/contact",
controller: "contactCtrl",
controllerAs: "vm",
templateUrl: "App/admin/templates/contact.html",
resolve: {
loadFunctionalityFiles: ["$ocLazyLoad", function ($ocLazyLoad) {
return $ocLazyLoad.load({
serie: true,
files: [
"App/admin/factories/userFactory.js",
"App/admin/controllers/contactController.js"
]
});
}]
}
});
最后,这是文档,以防万一:Angular-Formly extension types