Javascript AngularJS组件绑定在minified上未定义
我的应用程序有问题。当我使用Javascript AngularJS组件绑定在minified上未定义,javascript,angularjs,recursion,binding,components,Javascript,Angularjs,Recursion,Binding,Components,我的应用程序有问题。当我使用grunt-serve构建它时,一切都很正常,但当我尝试将其构建到dist时,似乎我的组件的绑定以某种方式失败了。代码如下所示: angular.module('jsonParserApp') .component('leafTemplate', { templateUrl: 'views/itemList.html', bindings: { readonly: '<', //other bindings (works properly
grunt-serve
构建它时,一切都很正常,但当我尝试将其构建到dist时,似乎我的组件的绑定以某种方式失败了。代码如下所示:
angular.module('jsonParserApp')
.component('leafTemplate', {
templateUrl: 'views/itemList.html',
bindings: {
readonly: '<',
//other bindings (works properly)
},
controller: ['$scope', 'copiedValue', function($scope, copiedValue) {
//code
this.$onChanges = function(changesObj) {
console.log('onChanges', changesObj);
//code
};
//code
}]
});
<leaf-template k="key" t="ctrl.t[ctrl.k]" i="{{$index}}" readonly="ctrl.readonly" parent="{{ctrl.parent + '.' + ctrl.k}}"></leaf-template>
但是,当我查看grunt
的dist上的记录值时,它会返回
{
"readonly": {
"currentValue": true,
"previousValue": UNINITIALIZED_VALUE
}
}
{
"readonly": {
"currentValue": undefined,
"previousValue": UNINITIALIZED_VALUE
}
}
值得一提的是,这些组件是递归构建的。html中的代码大致如下:(代码的第一个示例是将值初始化为readonly为true或false,然后应该将其传播到子元素)
问题是什么,为什么不在缩小/丑陋版本上传播该值
@更新
我试着调试它,发现了一些非常有趣的东西。在构建之前,html如下所示:
angular.module('jsonParserApp')
.component('leafTemplate', {
templateUrl: 'views/itemList.html',
bindings: {
readonly: '<',
//other bindings (works properly)
},
controller: ['$scope', 'copiedValue', function($scope, copiedValue) {
//code
this.$onChanges = function(changesObj) {
console.log('onChanges', changesObj);
//code
};
//code
}]
});
<leaf-template k="key" t="ctrl.t[ctrl.k]" i="{{$index}}" readonly="ctrl.readonly" parent="{{ctrl.parent + '.' + ctrl.k}}"></leaf-template>
在dist版本中,$templateCache包含如下所示的html
<leaf-template k="key" t="main.inputJson" i="{{$index}}" readonly parent="$"></leaf-template>
由于某些原因,
readonly=“ctrl.readonly”
被剪切为readonly将名称从readonly
更改为任何其他帮助。。。实际上,readonly
是HTML输入的属性,因此将readonly=“ctrl.readonly”
解析为只readonly
如果您解决了问题,最好回答您的问题。这样其他人就会知道问题已经解决了。你也可以通过接受答案给自己打分。:-)谢谢你的建议。:)哥们,这真的帮了我的忙:D