Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. <span ng-switch on="editgroupChatFieldFlag" style="width: 87%;margin-right: 0;float:left;" ng-hide="displatSessionTitleFlag==false">
  2. <h5 style="float:left;margin: 7px 14px 0;margin-right: 0;">Chat Session : </h5>
  3. <a ng-switch-when="true" contenteditable="true" strip-br="true" ng-model="chatMessageName" style="margin-right: 0;width: 59%;margin-left: 4px;" ng-keydown="changeNameFunc($event)">{{secondPresonName}}</a>
  4. <a ng-switch-when="false" style="margin-right: 0;width: 59%;margin-left: 4px;">{{secondPresonName}}</a>
  5. </span>
  6.  
  7. app.directive('contenteditable', function() {
  8. return {
  9. restrict: 'A', // only activate on element attribute
  10. require: '?ngModel', // get a hold of NgModelController
  11. link: function(scope, element, attrs, ngModel) {
  12. if(!ngModel) return; // do nothing if no ng-model
  13.  
  14. // Specify how UI should be updated
  15. ngModel.$render = function() {
  16. element.html(ngModel.$viewValue || '');
  17. };
  18.  
  19. // Listen for change events to enable binding
  20. element.on('blur keyup change', function() {
  21. scope.$apply(read);
  22. });
  23. read(); // initialize
  24. // Write data to the model
  25. function read() {
  26. var html = element.html();
  27. // When we clear the content editable the browser leaves a <br> behind
  28. // If strip-br attribute is provided then we strip this out
  29. if( attrs.stripBr && html == '<br>' ) {
  30. html = '';
  31. }
  32. ngModel.$setViewValue(html);
  33. }
  34. }
  35. };
  36. });
  37.  
  38. <a ng-switch-default contenteditable="true"
  39. strip-br="true"
  40. ng-model="$parent.chatMessageName" >Enter</a>
  41.  
  42. --controller
  43. $scope.myType = {
  44. chatMessageName: ''
  45. };
  46.  
  47. <!-- html -->
  48. <a ng-switch-default
  49. contenteditable="true"
  50. strip-br="true"
  51. ng-model="myType.chatMessageName" >Enter</a>
  52. <a>{{"Text "+ myType.chatMessageName}}</a>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement