Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. function PostCtrl($scope,$http, $compile, $rootScope, CONFIG) {
  2.  
  3.  
  4. $scope.patternUrl = (function() {
  5. var regexp = /(https?://[^s]+)/gi;
  6. return {
  7. test: function(value) {
  8. //return regexp.test(value);
  9. if (regexp.test(value)) {
  10. $scope.form = {
  11. name: name,
  12. }
  13.  
  14. return $scope.$watch('form', function(newVal, oldVal){
  15. $http({
  16. url: CONFIG.APIURL + 'post/ajaxcheck',
  17. method: "POST",
  18. data: {'query':newVal}
  19. }).success(function (data, status, headers, config) {
  20. var publisher = $('.timeline');
  21.  
  22. publisher.data('scrabing', data);
  23. var template = "<div ng-repeat='item in items' ng-include='users.html'></div>";
  24. $('.publisher-timeline').html(template).fadeIn();
  25.  
  26. var scope = $rootScope.$new();
  27. scope.items = [ { name: data.data }, { name: 'Tu' } ];
  28. $compile(document.getElementById('pub'))(scope);
  29. }).error(function (data, status, headers, config) {
  30. //ERROR
  31.  
  32.  
  33. });
  34.  
  35.  
  36. }, true);
  37.  
  38.  
  39. }
  40. }
  41. };
  42. })();
  43.  
  44.  
  45. }
  46.  
  47. <div class="mdl-grid" ng-controller="PostCtrl">
  48. <div class="publisher-timeline" id="pub">
  49. <script type="text/ng-template" id="users.html">
  50. <p>{{ item.title }}</p>
  51. </script>
  52. </div>
  53. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement