我在這裏創建了自定義指令進行表演和JSON數據隱藏特定領域不工作,在這裏我的問題是角版本,低版本的工作(https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js),但高版本的不支撐(https://code.angularjs.org/1.3.15/angular.js)NG-節目基礎上,AngularJs版本
請檢查下面的鏈接 http://plnkr.co/edit/h3MrWQjopbqzYa0Y5pOT?p=preview
變種應用= 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;
}]);
請告訴我,什麼是錯的,而無需點擊任何鏈接。你粘貼了一層代碼,它有什麼問題,你認爲問題在哪裏?聲明「ng-show」在某些較新版本的Angular中不起作用並不是很有用。如果它不工作,你不會是唯一有這個問題的人。 –
請查看此網址http://plnkr.co/edit/h3MrWQjopbqzYa0Y5pOT?p=preview和編輯https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js到https: //code.angularjs.org/1.3.15/angular.js – Nelson
你有沒有做過什麼來縮小問題的範圍? –