ng-show not working based on the AngularJs version -


here created custom directive show , hide particular field json data , here problem angular version, in low version working ( https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js), high version not supporting (https://code.angularjs.org/1.3.15/angular.js)

please check below link http://plnkr.co/edit/h3mrwqjopbqzya0y5pot?p=preview

var app = angular.module('testapp', []);

app.directive('telbasictext1', ['$http', 'telngshowservice', function($http, telngshowservice) {   return {     restrict: 'aec',     require: 'ngmodel',     scope: {       ngmodel: '=',       placehold: '@',       checkid: '@',       classname: '@',       ngmaxlength: '@',       ngminlength: '@',       lblvalue: '@',       textboxsize: '@',       lblsize: '@',       validate: '@',       ngshow: '@',       textboxtype: '@',       getstring: '@',       position: '@',       labelposition: '@',       textboxposition: '@',       canshow: '@',       showorhide: '@',     },     template: '<div   id="{{ checkid }}" class="form-group" ng-show="true"  > ' +       '<label size="lblsize"  class="col-sm-{{ labelposition }} control-label" id="textboxchanges">   test </label>' +       '<div class="col-sm-{{ textboxposition }}"> <input type="{{ textboxtype }}" ng-model="ngmodel" placeholder="{{ placehold }}"  id="{{checkid}}"   class="{{classname}}"  minlength="{{ ngminlength }}"  maxlength="{{ ngmaxlength }}"  size="{{ textboxsize }}"           ng-required="{{ validate }}" ></div></div>',      link: function(scope, ielement, iattrs, ngmodelcontroller) {          var ngshow = iattrs.canshow;       var ngsplitvalues = ngshow.split(",");       var nglanguage = ngsplitvalues[0]; // language en or fr       var nglabelname = ngsplitvalues[1]; // label name       var ngmodulename = ngsplitvalues[2]; // module name (global or local)        telngshowservice.getdata(ngmodulename).success(function(data) {          scope.showorhide = data[nglabelname];         console.log(scope.showorhide)         })       }   }; }]);    app.factory('telngshowservice', ['$http', function($http) {   var datafactory = {};   var lang = window.localstorage.language;   datafactory.getdata = function(modulename) {      if (modulename == 'common') {        return $http.get(labeli18npath + '/translation_' + lang + '.json');     } else {         return $http.get('oplayout.json');     }   };   return datafactory; }]); 

this due breaking changes in $parse service in version 1.3.0-beta.14:

core: due bdfc9c02, values 'f', '0', 'false', 'no', 'n', '[]' no longer treated falsy. javascript falsy values treated falsy expression parser; there 6 of them: false, null, undefined, nan, 0 , "".

use booleans instead of strings:

{     "psearchpatient": false,     "paddressno" : true,     "pbuilding": true } 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -