반응형

sample Json 

{message:[{name:test1,desc:test1desc},{name:test2,desc:test2desc}]}



.js

.controller('cartCtrl', ['$scope', '$http', function ($scope, $http) {

$http({

                        method: 'POST',

                        url: URL,

                        data: $.param({

                        }),

                        headers: {

                            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'

                        }

                    }).success(function (response) {

                        $scope.itemList = response.message;


                    }).finally(function () {

                    });

}])

.directive('itemListRepeatDone', function () {

            return function (scope, element, attrs) {

                if (scope.$last) {

                   //생성이 끝난뒤 핸들링

                }

            }

        })


.html


<div class="col-md-4 col-sm-6" ng-repeat="item in itemList" item-list-repeat-done>

  <h4 data-name="product_name">{{ item.name }}</h4>

  <p data-name="product_desc">{{ item.desc }}</p>

</div>

반응형

'FrontEnd > angularJS' 카테고리의 다른 글

ngRoute를 이용한 싱글 페이지 웹 앱  (0) 2018.12.12
블로그 이미지

앱스페이스

,
반응형

$http({

                        method: 'POST', //or GET

                        url: URL,

                        data: $.param({

                        }),

                        headers: {

                            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'

                        },

                        responseType: "blob"

                    }).success(function (response) {

                        

                        //이미지 지정

                        var urlCreator = window.URL || window.webkitURL;

                        var imageUrl = urlCreator.createObjectURL(response);

                        $('.img').attr("src", imageUrl);


                    }).finally(function () {

                    });

반응형

'FrontEnd > javascript' 카테고리의 다른 글

자바스크립트로 css생성 하기  (0) 2018.12.12
블로그 이미지

앱스페이스

,
반응형

index.html


<body ng-app="myApp">

        <div class="container">

            <ng-view></ng-view> <-- ng-view 위치에 page1.html, page2.html 내용이 보여짐-->

        </div>

    </body>


page1.html


page2.html


.js

angular.module('myApp', ['ngRoute'])

        /*뷰 설정*/

        .config(function ($routeProvider) {

            $routeProvider

                    .when('/page1', {templateUrl: 'page1.html', controller: 'page1Ctrl'})

                    .when('/page2', {templateUrl: 'page2.html', controller: 'page2Ctrl'})

                    .otherwise({redirectTo: '/page1'}); //기본 페이지


        })

.controller('page1Ctrl', ['$scope', '$http', function ($scope, $http) {


            }])

.controller('page2Ctrl', ['$scope', '$http', function ($scope, $http) {


            }]);

반응형

'FrontEnd > angularJS' 카테고리의 다른 글

ng-repeat을 이용한 div 동적 생성  (0) 2018.12.12
블로그 이미지

앱스페이스

,
반응형

var mySheet = document.styleSheets[0] 일때

 

if(!mySheet) {

    var stylesheet = document.createElement("style");

    stylesheet.setAttribute("type", "text/css");

    document.getElementsByTagName('head')[0].appendChild(stylesheet);

    mySheet = document.styleSheets[0];

}

반응형
블로그 이미지

앱스페이스

,