I am creating a simple angularjs application and I am trying to embed a login without refreshing the page.
What am I doing
On startup, ng-include loads /set/save./Set/save got <a fblogin>Login with Facebook</a> in it. Therefore, when you click this directive, a window opens, and when the window closes, it should change src ng-include.
Problem
When the directive is used inside ng-include (ng-include src has a default value for init) nothing happens (there are no errors in the console, just nothing), but when I put the directive outside of ng-include, it works fine (see HTML code below)
HTML:
<div id="set-creator" ng-controller="SetCtrl"> ........ <div id="saveModal" class="reveal-modal" data-reveal> <a href fblogin>testCase</a> // ^this is working //but if the directive is inside ng-include, it not working <ng-include src="saveTemplate"></ng-include> <a class="close-reveal-modal">×</a> </div> </div>
Directive
App.directive('fblogin', function() { return { transclude: false, link: function(scope, element, attrs) { element.click(function() { var win = window.open("/auth/facebook", 'popUpWindow', 'centerscreen=true'); var intervalID = setInterval(function() { if (win.closed) { scope.saveTemplate = '/set/continue'; scope.$apply(); clearInterval(intervalID); } }, 100); }); } }; });
Controller:
App.controller("SetCtrl", ["$scope", "SetHolder", function($scope, SetHolder) { $scope.saveTemplate = '/set/save'; $scope.test = "loaded"; } ]);
And / set / save
You need to be logged in order to save the set. <br /> <a fblogin>Login with Facebook</a>
javascript angularjs templates angularjs-directive angularjs-ng-include
Deepsy
source share