Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 动画中的装饰器不支持函数调用_Angular_Angular8_Angular Aot - Fatal编程技术网

Angular 动画中的装饰器不支持函数调用

Angular 动画中的装饰器不支持函数调用,angular,angular8,angular-aot,Angular,Angular8,Angular Aot,错误 src/app/components/register/registration form/registration form.component.ts(27,18): “RegistrationFormComponent”的模板编译过程中出错 decorators中不支持函数调用,但“getanimationRule” 有人打电话来 注册表单组件 @Component({ selector: 'app-registration-form', templateUrl: './reg

错误 src/app/components/register/registration form/registration form.component.ts(27,18): “RegistrationFormComponent”的模板编译过程中出错
decorators中不支持函数调用,但“getanimationRule” 有人打电话来

注册表单组件

@Component({
  selector: 'app-registration-form',
  templateUrl: './registration-form.component.html',
  styleUrls: ['./registration-form.component.scss'],
  animations:[getanimationRule(registerChildrens)]
})
getanimationRule

export function  getanimationRule(routeCollection: Routes)  {
    const routeArray = routeCollection.map(o => o.data && o.data.animation ? o.data.animation : null)
    .filter((el) => el != null);
    const animationRules = [];
    routeArray.forEach((element, value) => {
        if (element != null) {
            if (value === 0) {
                animationRules.push(transition(element + ' => *', animationDOWN));
            } else if (value === routeArray.length - 1) {
                animationRules.push(transition(element + '=> *', animationUP));
            } else {
                routeArray.forEach((subelement, subvalue) => {
                    if (subelement != null) {
                        if (subvalue < value) {
                            animationRules.push(transition(element + ' => ' + subelement, animationUP));
                        } else if (subvalue > value) {
                            animationRules.push(transition(element + ' => ' + subelement, animationDOWN));
                        }
                    }
                });
            }
        }
    });

    return trigger('routeAnimations',animationRules );
};
导出函数getanimationRule(routeCollection:Routes){
const routarray=routeCollection.map(o=>o.data&&o.data.animation?o.data.animation:null)
.filter((el)=>el!=null);
常量animationRules=[];
routeArray.forEach((元素,值)=>{
if(元素!=null){
如果(值==0){
push(转换(元素+'=>*',animationDOWN));
}else if(值===routeArray.length-1){
push(转换(元素+'=>*',animationUP));
}否则{
routeArray.forEach((子元素,子值)=>{
if(子元素!=null){
if(子值<值){
push(转换(元素+'=>'+子元素,animationUP));
}else if(子值>值){
push(转换(元素+'=>'+子元素,animationDOWN));
}
}
});
}
}
});
返回触发器('routeAnimations',animationRules);
};

不幸的是,您不能在component decorator内部调用函数,您可以将其作为引用传递,如

animations: [getanimationRule] 
请点击此链接了解更多信息->