Advertisement
febripratama

angular-scope-problem

Feb 16th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* route menggunakan ui*/
  2.  
  3.     $stateProvider.state('member',{
  4.         url : '/',
  5.         templateUrl : '../js/templates/brand/home.html',
  6.         controller: 'BrandCtrl'
  7.     })
  8.  
  9. /* controller */
  10. controller('BrandCtrl', function ($scope, ModalService, config, $ocLazyLoad, Brand, Auth, other) {
  11.  
  12.     /* page config */
  13.     $scope.config = config.brand();
  14.     $scope.isCollapsed = true;
  15.     $scope.buttonOpacity = 1;
  16.     $scope.alerts = [];
  17.  
  18.     $scope.closeAlert = function(index) {
  19.  
  20.         $scope.alerts.splice(index, 1);
  21.  
  22.     };
  23.  
  24.     /* brand modal */
  25.     $scope.brandModal = function(){
  26.  
  27.         ModalService.trigger($scope.config.main + 'js/templates/brand/modal-brand-create.html','BrandCtrl');
  28.  
  29.     };
  30.  
  31.     /* brand submit */
  32.     $scope.BrandSubmit = function(isValid){
  33.  
  34.         if (isValid) {
  35.  
  36.             Brand.save(Auth.getToken(),$scope.brandCreate).success(function(data) {
  37.  
  38.                     /* Brand Data refresh*/
  39.                     $scope.brand.push(data.data);
  40.                     $scope.alerts.push({ type: 'success', msg: 'Your Brand is ready !' });
  41.                     $scope.brandCreate = {};
  42.  
  43.             })
  44.             .error(function(data) {
  45.  
  46.                 console.log(data);
  47.                
  48.             });
  49.  
  50.         }
  51.     };
  52.  
  53.  })
  54.  
  55. /* view */
  56.  
  57.       <h4 class="panel-title" style="font-size:25px" ng-show="!brand.length">
  58.         No Brands, start create one !
  59.         <hr>
  60.       </h4>    
  61.  
  62.       <table class="table" ng-show="brand.length">
  63.  
  64.           <tr ng-repeat="data in brand">
  65.  
  66.               <span class="label label-primary">{{ data.name }}</span>
  67.  
  68.           </tr>
  69.       </table>
  70.     </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement