Advertisement
Guest User

Untitled

a guest
Jun 28th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. <p>Current url = {{url}}</p>
  2.  
  3. app.controller('MainController', function($scope) {
  4. // This is the inital url
  5. // It shows up in the HTML fragment
  6. $scope.url = "http://stackoverflow.com";
  7. });
  8.  
  9. webview.addEventListener('loadcommit', function() {
  10. url = webview.src;
  11. //How to update Angular framework with current value of url?
  12. }
  13.  
  14. $scope.url = url;
  15.  
  16. <div ng-controller="MainController">
  17. <webview current-src="url" id="foo"
  18. src="http://stackoverflow.com/"
  19. style="width:640px; height:480px">
  20. </webview>
  21.  
  22. <p>Current url = {{url}}</p>
  23. </div>
  24.  
  25. app.directive("webview",function() {
  26. return {
  27. restrict: "E",
  28. link: function(scope,elem,attrs) {
  29. var webview=elem[0];
  30. elem.on("loadcommit", function(e) {
  31. $scope.$apply(attrs.currentSrc +'='+ webview.src);
  32. };
  33. }
  34. };
  35. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement