2

Here i am created custom directive for show and hide particular field from json data , here my problem is angular version, in low version its working ( https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js), but high version its not supporting (https://code.angularjs.org/1.3.15/angular.js)

please check the 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;
}]);
3

1 Answer 1

2

This is due to breaking changes in the $parse service in version 1.3.0-beta.14:

core: due to bdfc9c02, values 'f', '0', 'false', 'no', 'n', '[]' are no longer treated as falsy. Only JavaScript falsy values are now treated as falsy by the expression parser; there are six of them: false, null, undefined, NaN, 0 and "".

Use booleans instead of strings:

{
    "pSearchPatient": false,
    "pAddressNo" : true,
    "pBuilding": true
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.