Add controllers

This commit is contained in:
Philippe Vienne 2016-04-17 20:37:09 +02:00
parent bd7abbe54d
commit fc7848a43e
2 changed files with 34 additions and 5 deletions

View file

@ -26,12 +26,12 @@
<ul class="nav navbar-nav">
<li class="active"><a href="#">Finder</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<ul class="nav navbar-nav navbar-right" ng-controller="AuthCtrl">
<li ng-if="access_token == ''">
<a href="#/login" class="dropdown-toggle" data-toggle="dropdown"><b>Login With Spotify</b></a>
<a href="#" ng-click="login()" class="dropdown-toggle" data-toggle="dropdown"><b>Login With Spotify</b></a>
</li>
<li ng-if="access_token != ''">
<a href="#/refresh-token" class="dropdown-toggle" data-toggle="dropdown"><b>Refresh my token</b></a>
<a href="#" ng-click="refresh()" class="dropdown-toggle" data-toggle="dropdown"><b>Refresh my token</b></a>
</li>
</ul>
</div><!-- /.navbar-collapse -->

View file

@ -37,9 +37,38 @@
$urlRouterProvider.otherwise("/");
}]);
app.run(['$rootScope',function($rootScope){
$rootScope.access_token = "";
$rootScope.refresh_token = "";
}]);
app.controller("HomeCtrl",['$scope',function($scope){
}]);
app.controller("MainCtrl",['$scope',function($scope){
}]);
app.controller("PlaylistCtrl",['$scope',function($scope){
}]);
app.controller("DupsCtrl",['$scope',function($scope){
}]);
app.controller('AuthCtrl',['$scope', '$rootScope', function($scope, $rootScope){
$rootScope.access_token = "Bonjour";
$rootScope.refresh_token = "Bonjour2";
$scope.login = function(){
var openUrl = '/login';
window.$windowScope = $scope;
window.open(openUrl, "Authenticate Account", "width=500, height=500");
};
$scope.refresh = function(){
var openUrl = '/refresh_token';
window.$windowScope = $scope;
window.open(openUrl, "Authenticate Account", "width=500, height=500");
}
}])
})();