Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. <div class="col-md-8" ng-class="{'has-error': hasError(profile_form.facebook)}">
  2. <div class="input-group">
  3. <span class="input-group-addon">
  4. <i class="fa fa-facebook fa-input-group" ng-style="{color: '#3b5998'}"></i>
  5. </span>
  6. <input class="form-control" type="url" ng-model="share['facebook'].url"
  7. placeholder="Ex: https://www.facebook.com/empresa"
  8. name="facebook" ng-required="share['facebook'].show" validate-url>
  9. <span class="input-group-addon">
  10. <input type="checkbox" ng-model="share['facebook'].show">
  11. </span>
  12. </div>
  13. <div ng-show="hasError(profile_form.facebook)" ng-messages="profile_form.facebook.$error" class="help-block">
  14. <div ng-message="url"> Invalid Address</div>
  15. <div ng-message="required"> Campo obrigatório</div>
  16. </div>
  17. </div>
  18.  
  19. <social-network ng-model="share" color="#3b5998" icon="facebook"
  20. placeholder="Ex: https://www.facebook.com/empresa"
  21. component="profile_form.facebook"/>
  22.  
  23. angular.module("app").directive("socialNetwork", function () {
  24. return {
  25. templateUrl: "templates/socialNetwork.html",
  26. replace: true,
  27. restrict: "E",
  28. transclude: true,
  29. require: ['^?validateUrl', '^?ngMessages', 'ngModel'],
  30. scope: {
  31. 'ngMessages': '=',
  32. 'ngModel': '=',
  33. 'icon': '@',
  34. 'color': '@',
  35. 'placeholder': '@',
  36. 'component': '@'
  37. },
  38. link: function($scope, $element, $attrs, ngModel){
  39. $scope.hasError = function (field, arg2, arg3) {
  40. if (field) {
  41. console.log(field.$name);
  42. }
  43. }
  44. }
  45. };
  46. });
  47.  
  48. <div class="input-group" ng-class="{'has-error': hasError({{component}})}">
  49. <span class="input-group-addon">
  50. <i class="fa fa-{{icon}} fa-input-group" ng-style="{color: '{{color}}'}"></i>
  51. </span>
  52. <input class="form-control" type="url" ng-model="ngModel[icon].url" placeholder="{{placeholder}}" name="{{icon}}" required validate-url>
  53. <span class="input-group-addon">
  54. <input type="checkbox" ng-model="ngModel[icon].show">
  55. </span>
  56. </div>
  57. <div ng-show="hasError({{component}})" ng-messages="component.$error" class="help-block">
  58. <div ng-message="url"> Endereço inválido</div>
  59. <div ng-message="required"> Campo obrigatório</div>
  60. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement