Skip to content

Instantly share code, notes, and snippets.

@liorkesos
Last active December 17, 2015 01:28
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save liorkesos/5528234 to your computer and use it in GitHub Desktop.
Save liorkesos/5528234 to your computer and use it in GitHub Desktop.
A sequence of files which get called and enable an angular.js app The app structure looks like this
window.app = angular.module('myApp', ['ngCookies', 'ngResource']);
//Setting up route
window.app.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/', { redirectTo: '/home' }).
when('/home', { templateUrl: 'views/main.html' }).
when('/youtube', { templateUrl: 'views/youtube.html' }).
when('/404', { templateUrl: 'views/404.html' }).
otherwise({redirectTo: '/404'});
}]);
app
index.html
app.js
css/
js/
controllers/
youtubeSearch.js
services/
views/
main.html
404.html
<html data-ng-app="myApp">
<link rel="stylesheet" href="css/lib/bootstrap.min.css">
<body>
<section class="content" data-ng-view></section>
</body>
<script src="js/lib/angular.min.js"></script>
<script src="js/lib/angular-cookies.min.js"></script>
<script src="js/lib/angular-resource.min.js"></ script>
<script src="js/app.js"></script>
<script src="js/directives.js"></script>
<script src="js/youtubeSearch.js"></script>
</html>
<h1> My Youtube Search app</h1>
<div data-ng-include="'views/navigation.html'"></div>
<div ng-app="youtubeSearchApp" data-ng-controller="youtubeSearchController">
<div class="player">
<div data-ng-include="'views/bigVideo.html'" ></div>
</div>
<div class="wrap">
<div class="search" data-ng-include="'views/searchYouTube.html'"></div>
</div>
<div class="playlist" data-ng-include="'views/playListYouTube.html'"> </div>
</div>
function youtubeSearchController($scope, YouTube, Cube) {
$scope.CubeService = Cube;
$scope.stores=[];
$scope.doSearch = function(query){
if (query=="")
query=query+'?';
if (query!=null)
$scope.videos = YouTube.get({q: query});
}
$scope.doStore=function (video) {
$scope.stores.push(video);
console.log($scope.stores);
}
$scope.doBig=function (video) {
$scope.BigVideo=video;
}
$scope.remove = function ( idx ) {
var store_to_delete = $scope.stores[idx];
$scope.stores.splice( $scope.stores.indexOf(store_to_delete), 1 );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment