

function EditMovieCtrl(MovieService,$stateParams) {

  // ViewModel
  const edit = this;
  edit.title = 'Edit Movies' + $stateParams.id;
  edit.back = function(){
    window.history.back()
  }
  edit.checker = function(bool){
    if(bool=='true')  
      return true;
    if(bool=='false')  
      return false;
  }
  edit.click = function(bool,key){
    edit.data[key] = !bool
  }
  MovieService.getID($stateParams.id).then(function(results){
    if(results.status===404)
      edit.data.movies='not found'
    
    edit.data = results

  })
  // MovieService.get().then(function(results){
  //   edit.movies = results
  // })

  edit.processForm = function(){
    
    MovieService.put(edit.data).then(function(res){
      console.log(res)
    })
  }

  

}
EditMovieCtrl.$inject=['MovieService','$stateParams']
export default {
  name: 'EditMovieCtrl',
  fn: EditMovieCtrl
};

