根据AngularJs版本显示不工作

在这里我创建自定义指令显示和隐藏JSON数据的特定字段,在这里我的问题是角度版本,在低版本其工作(https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular .min.js),但高版本不支持(https://code.angularjs.org/1.3.15/angular.js)

请检查以下链接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;
}]);

这是由于在1.3.0-beta.14版本中突破了$parse服务中的更改

核心 :由于bdfc9c02,值'f','0','假','不','n','[]'不再被视为虚假。 现在只有JavaScript错误值被表达式解析器当作虚假处理; 有六个:false,null,undefined,NaN,0和“”。

使用布尔值代替字符串:

{
    "pSearchPatient": false,
    "pAddressNo" : true,
    "pBuilding": true
}
链接地址: http://www.djcxy.com/p/77701.html

上一篇: show not working based on the AngularJs version

下一篇: sorting list by select element item using angular js