javascript - angularjs accessing ng-model from outside the $scope -


here code:

<div class="row">         <div class="col-md-3 col-sm-4">             <checked-input              pholder="{{'publications-customdomain' | translate}}"              class="add-publisher-input"              ng-model="customdomain"              icon="glyphicon-globe"              type="publicationcustomdomain"              page="publications">             </checked-input>         </div>         <div class="col-md-3 col-sm-4">             <button class="add-domain btn btn-primary disabled-btn" ng-model="adddomainbtn" ng-click="vm.adduserpublisher(currenttab)">                 <span class="glyphicon glyphicon-plus"></span>{{'publications-adddomain' | translate}}             </button>         </div>     </div> 

inside file directives.ts, have structure goes through bunch of if/else-ifs figure out user has selected:

else if($scope.type == "publicationcustomdomain") {       var isurl;       var custdomregex = /^(?!http)(www\.)?(([a-z])+\.[a-z]{2,}(\.[a-z]{2,})?)/i;       var iscustdom;       var custdomname = e.target.value;       if (custdomname.match(custdomregex)) {         iscustdom = true;       } else {         iscustdom = false;       }       if(iscustdom) {         inform.attr('class', 'input-inform state-normal');         inform.html('enter custom domain name');         inputstate.attr('class', 'input-group-addon glyphicon glyphicon-ok input-state');         inform.animate({top: '28px'}, 'slow');         //here want remove class 'disabled-btn' button ng-model 'adddomainbtn'       } 

obviously if($scope.type == "publicationcustomdomain") evaluates true, $scope here inside first nested div, checked-input tag. can write in line have commented out access button inside second nested div remove class specified?

edit:

the controller defined so...

class mainpublicationsctrl {     private scope: any;     private timeout: any;     private modal: any;     private route: any;     private http: any;     private mainscope: any;     private selsiteserv: any;     static $inject = ['$scope'];      constructor($scope, $timeout, $http, $modal, $route, selsiteserv) {         $scope.vm = this;         $scope.isbtnclassdisabled = true;         $scope.selecteditem = 0;         $scope.countoftabs = 1;         $scope.activetab = {             num: 0         };         $scope.publisheraddtext = {             text: ""         };         ... 

create new property in ctrl... default true ->

 isbtnclassdisabled = true; 

now in html this:

 <div class="row">             <div class="col-md-3 col-sm-4">                 <checked-input                  pholder="{{'publications-customdomain' | translate}}"                  class="add-publisher-input"                  ng-model="customdomain"                  icon="glyphicon-globe"                  type="publicationcustomdomain"                  page="publications"                  buttonclass="isbtnclassdisabled">                 </checked-input>             </div>             <div class="col-md-3 col-sm-4">                 <button class="add-domain btn btn-primary " ng-model="adddomainbtn" ng-click="vm.adduserpublisher(currenttab)"  ng-class="disabled-btn : isbtnclassdisabled ">                     <span class="glyphicon glyphicon-plus"></span>{{'publications-adddomain' | translate}}                 </button>             </div>         </div> 

and now, directive.ts this:

else if($scope.type == "publicationcustomdomain") {       var isurl;       var custdomregex = /^(?!http)(www\.)?(([a-z])+\.[a-z]{2,}(\.[a-z]{2,})?)/i;       var iscustdom;       var custdomname = e.target.value;       if (custdomname.match(custdomregex)) {         iscustdom = true;       } else {         iscustdom = false;       }       if(iscustdom) {         inform.attr('class', 'input-inform state-normal');         inform.html('enter custom domain name');         inputstate.attr('class', 'input-group-addon glyphicon glyphicon-ok input-state');         inform.animate({top: '28px'}, 'slow');         $scope.isbtnclassdisabled = false;       } 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -