Some questions for Angular 4

See All Questions HereCategory: BugSome questions for Angular 4
popularsoftTan asked 3 weeks ago

when i use the Component(saUiValidate) to test,after test successfully,calling my own method failed.
Please help, thank you!

Error Message:
ERROR TypeError: this.editRole is not a function
    at $.validator.webpackJsonp.1122.RoleComponent.onSubmit (http://localhost:4200/0.chunk.js:4144:14)
    at handle (http://localhost:4200/23.chunk.js:88:49)
    at HTMLFormElement.<anonymous> (http://localhost:4200/23.chunk.js:112:13)
    at HTMLFormElement.dispatch (http://localhost:4200/vendor.bundle.js:56896:27)
    at HTMLFormElement.elemData.handle (http://localhost:4200/vendor.bundle.js:56708:28)
    at ZoneDelegate.invokeTask (http://localhost:4200/polyfills.bundle.js:6754:31)
    at Object.onInvokeTask (http://localhost:4200/vendor.bundle.js:4499:37)
    at ZoneDelegate.invokeTask (http://localhost:4200/polyfills.bundle.js:6753:36)
    at Zone.runTask (http://localhost:4200/polyfills.bundle.js:6521:47)
    at HTMLFormElement.ZoneTask.invoke (http://localhost:4200/polyfills.bundle.js:6816:38)defaultErrorLogger @ core.es5.js:1084ErrorHandler.handleError @ core.es5.js:1144next @ core.es5.js:4778schedulerFn @ core.es5.js:3851SafeSubscriber.__tryOrUnsub @ Subscriber.js:238SafeSubscriber.next @ Subscriber.js:185Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ core.es5.js:3837NgZone.triggerError @ core.es5.js:4209onHandleError @ core.es5.js:4170ZoneDelegate.handleError @ zone.js:395Zone.runTask @ zone.js:194ZoneTask.invoke @ zone.js:486

在.ts文件中代码如下

// validation
  public validationOptions:any ={
    rules : {
      roleId : {
        required : true,
        maxlength: 32,
        txtHalfInput :true
      },
      roleName : {
        required : true
      },
      startDate : {
        required : true
      },
      endDate : {
        required : true
      },
      displayOrder : {
        required : true,
        maxlength: 3,
        digits: true
      }
    },

    // Messages for form validation
    messages : {
      roleId : {
        required : ‘messages’,
        maxlength: ‘messages’,
        txtHalfInput: ‘messages’
      },
      roleName : {
        required : ‘messages’
      },
      startDate : {
        required : ‘messages’
      },
      endDate : {
        required : ‘messages’
      },
      displayOrder : {
        required : ‘messages’,
        maxlength: ‘messages’,
        digits: ‘messages’
      }
    },
    submitHandler: this.onSubmit
  };

  onSubmit(){
     this.editRole();
  }

 public editRole(){
    this.startDate = $(‘#startDate’).val();
    this.endDate = $(‘#endDate’).val();

    if(this.action != ‘edit’){
        //add
      this.ExclusiveObject = ”;
      this.roleservice.
        addRole(this.getModifyParm())
        .then(r => {
          this.Message(r.Message, r.Success);
        });
    }else{
      // edit
      this.roleservice.
        editRole(this.getModifyParm())
        .then(r => {
          this.Message(r.Message, r.Success);
        });
    }

  }
 
1.There’re some errors during ng build .(Angular 4)(ng build -prod)(lite-version)
2.Is the project has the loading page ? eg click the button ,the page loading  circling in dark

ERROR in ./src/main.ts
Module not found: Error: Can’t resolve ‘./$$_gendir/app/app.module.ngfactory’ in
 ‘D:\Angular\05開発\lite-version\src’
 @ ./src/main.ts 5:0-74
 @ multi ./src/main.ts

ERROR in ./src/$$_gendir async
Module not found: Error: Can’t resolve ‘D:\Angular\05開発\lite-version\src\$$_ge
ndir\app\+home\home.module.ngfactory.ts’ in ‘D:\Angular\05開発\lite-version\src\
$$_gendir’
 @ ./src/$$_gendir async
 @ ./~/@angular/core/@angular/core.es5.js
 @ ./src/main.ts
 @ multi ./src/main.ts

0 Answers
MyOrange Staff answered 3 years ago

[dwqa-list-questions]

Leave a Reply