directivesModule.directive('custNgSearchE', function(browserInfoService){ var directiveTmplBaseUrl = browserInfoService.getTemplateBaseUrl('directives'); return{ restrict : 'E', templateUrl : directiveTmplBaseUrl + 'custNgSearchE.html', scope : { model : "=", search : "&", hascancel : "@", cancel : "&", memento : "=" }, link : { pre : function(scope,element,attrs){ scope.containerStyle = { width : attrs.containerWidth, background : '#81DAF5', padding : '5px' }; scope.textStyle = { width : attrs.inputWidth }; scope.labelText = attrs.labelText; if(scope.hascancel == 'yes'){ scope.$watch('memento',function(newValue,oldValue){ if(newValue != oldValue){ if(newValue != null && oldValue == null){ var value = parseInt(scope.containerStyle.width.substring(0,scope.containerStyle.width.indexOf("px"))); value += 115; scope.containerStyle.width = value + "px"; } else if(newValue == null && oldValue != null){ var value = parseInt(scope.containerStyle.width.substring(0,scope.containerStyle.width.indexOf("px"))); value -= 115; scope.containerStyle.width = value + "px"; } } },true); } }, post : function(scope,element,attrs){ } } }; });