load all javascript and angularjs code before rendering the html and directive in angularjs -


i using emojionearea in angularjs project . when parsed unicode emojis smiley faces using custom directive gives me error refrence error . emojione not defined . here directive

app.directive('emojifyit', emojifyit);  function emojifyit($timeout) {   console.log('directove bya sad')   return {     link : function(scope, element, attributes){       console.log(attributes['emojifyit']);       element.html(emojione.unicodetoimage(attributes['emojifyit']));     }   }; } 

if use $timeout function in works fine. e.g

app.directive('emojifyit', emojifyit);  function emojifyit($timeout) {   console.log('directove bya sad')   return {     link : function(scope, element, attributes){       console.log(attributes['emojifyit'])       $timeout(function() {                  element.html(emojione.unicodetoimage(attributes['emojifyit']))       }, 1000);         }   }; } 

is there solution dont use timeout function should load script , javascript code before rendering directive

my html code

 <span emojify-it="πŸ˜πŸ˜‚πŸ˜ƒasdπŸ˜ΆπŸ˜šπŸ˜™"></span>  

here complete html file edited

  <html>   <head>   <link rel="stylesheet" href="components/emojionearea/dist/emojionearea.min.css">  <script src="components/jquery/dist/jquery.js"></script>  <script src="components/emojionearea/dist/emojionearea.min.js"></script>  <title>  emoji example   </title>  <style> .ng-cloak { display: none !important; } </style>  </head> <body ng-app="emojiapp" ng-controller="mainctrl">      <span   emojify-it="πŸ˜πŸ˜‚πŸ˜ƒasdπŸ˜ΆπŸ˜šπŸ˜™"></span>      <script src="components/angular/angular.js"></script>  <script src="components/angular-sanitize/angular-sanitize.js"></script>  <script type="text/javascript" src="script.js"></script> </body> <script>   $(function(){     $("#emojionearea2").emojionearea({ pickerposition: "bottom", tonesstyle: "radio"  });   })  </script> 

want result without timeout check this

fiddle link fiddle link


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -