Last active
January 22, 2016 01:05
-
-
Save franklinjavier/841e9b27a517bc296745 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Created by Sandeep on 01/06/14. | |
| */ | |
| angular.module('movieApp',['ui.router','ngResource','movieApp.controllers','movieApp.services']); | |
| angular.module('movieApp').config(function($stateProvider){ | |
| $stateProvider.state('movies',{ | |
| url:'/movies', | |
| templateUrl:'partials/movies.html', | |
| controller:'MovieListController' | |
| }).state('viewMovie',{ | |
| url:'/movies/:id/view', | |
| templateUrl:'partials/movie-view.html', | |
| controller:'MovieViewController' | |
| }).state('newMovie',{ | |
| url:'/movies/new', | |
| templateUrl:'partials/movie-add.html', | |
| controller:'MovieCreateController' | |
| }).state('editMovie',{ | |
| url:'/movies/:id/edit', | |
| templateUrl:'partials/movie-edit.html', | |
| controller:'MovieEditController' | |
| }); | |
| }).run(function($state){ | |
| $state.go('movies'); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html data-ng-app="movieApp"> | |
| <head lang="en"> | |
| <meta charset="utf-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <base href="/"/> | |
| <title>The Movie App</title> | |
| <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/> | |
| <link rel="stylesheet" type="text/css" href="css/app.css"/> | |
| </head> | |
| <body> | |
| <nav class="navbar navbar-default" role="navigation"> | |
| <div class="container-fluid"> | |
| <div class="navbar-header"> | |
| <a class="navbar-brand" ui-sref="movies">The Movie App</a> | |
| </div> | |
| <div class="collapse navbar-collapse"> | |
| <ul class="nav navbar-nav"> | |
| <li class="active"><a ui-sref="movies">Home</a></li> | |
| </ul> | |
| </div> | |
| </div> | |
| </nav> | |
| <div class="container"> | |
| <!--<div class="jumbotron"> | |
| <h1>Welcome to Movie App!</h1> | |
| <p>App for Movie Lovers</p> | |
| </div>--> | |
| <div class="row top-buffer"> | |
| <div class="col-xs-8 col-xs-offset-2"> | |
| <div ui-view></div> | |
| </div> | |
| </div> | |
| </div> | |
| <script type="text/javascript" src="lib/angular.min.js"></script> | |
| <script type="text/javascript" src="js/app.js"></script> | |
| <script type="text/javascript" src="js/controllers.js"></script> | |
| <script type="text/javascript" src="js/services.js"></script> | |
| <script type="text/javascript" src="js/directives.js"></script> | |
| <script type="text/javascript" src="js/filters.js"></script> | |
| <script type="text/javascript" src="lib/angular-ui-router.min.js"></script> | |
| <script type="text/javascript" src="lib/angular-resource.min.js"></script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Created by Sandeep on 01/06/14. | |
| */ | |
| angular.module('movieApp.controllers',[]).controller('MovieListController',function($scope,$state,popupService,$window,Movie){ | |
| $scope.movies=Movie.query(); | |
| $scope.deleteMovie=function(movie){ | |
| if(popupService.showPopup('Really delete this?')){ | |
| movie.$delete(function(){ | |
| $window.location.href=''; | |
| }); | |
| } | |
| } | |
| }).controller('MovieViewController',function($scope,$stateParams,Movie){ | |
| $scope.movie=Movie.get({id:$stateParams.id}); | |
| }).controller('MovieCreateController',function($scope,$state,$stateParams,Movie){ | |
| $scope.movie=new Movie(); | |
| $scope.addMovie=function(){ | |
| $scope.movie.$save(function(){ | |
| $state.go('movies'); | |
| }); | |
| } | |
| }).controller('MovieEditController',function($scope,$state,$stateParams,Movie){ | |
| $scope.updateMovie=function(){ | |
| $scope.movie.$update(function(){ | |
| $state.go('movies'); | |
| }); | |
| }; | |
| $scope.loadMovie=function(){ | |
| $scope.movie=Movie.get({id:$stateParams.id}); | |
| }; | |
| $scope.loadMovie(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Created by Sandeep on 01/06/14. | |
| */ | |
| angular.module('movieApp.services',[]).factory('Movie',function($resource){ | |
| return $resource('/api/movies/:id',{id:'@_id'},{ | |
| update: { | |
| method: 'PUT' | |
| } | |
| }); | |
| }).service('popupService',function($window){ | |
| this.showPopup=function(message){ | |
| return $window.confirm(message); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment