javascript - How to bind ng-model to directive's scope -


i stcuked on binding ng-model inside directive's template html is

<input type="file" ng-model="uimg" value="test"/>  <button ng-click="upload(user,uimg)"         class="btn btn-default btn-sm">     <span class="glyphicon glyphicon-upload"></span> </button> 

as see have ng-model called "uimg" , when click button , function calls code

here directive class wrote

export class customdirective implements ng.idirective{

    public controller: any;     public restrict: string;     public templateurl: string;     public scope: object;     public link:ng.idirectivelinkfn;     public transclude:boolean;      constructor(restrict: string,         scope: object ,         controller: any,         templateurl: string,         link:any     ) {          this.restrict = restrict;         this.controller = controller;         this.templateurl = templateurl;         this.scope = scope;         this.link = link;         this.transclude = true;      }  } 

and register directive app.

app.directive("uploadkimlik", () => new application.directive.customdirective("a",     { user: "=",uimg:"=" },     "",     application.helper.generic.getpath() + "admin/gethtml/?id=upload",     (scope) => {         scope.upload=(u,i)=> {             alert("u john");             console.log(scope.user);             console.log(i);         };     })); 

first alert works , alerts "u john"
second console.log(scope.user) works ng-model created in directive returns undefined.

what wrong not understand.

any appreciated. thanks.


Comments