내맘대로 살기🎉
Angular의 철학,- 기능이 풍부한 동적 HTML을 생성해서 웹 클라이언트 측에서 많은 일을 보이지 않게 처리해준다.(view에서 거의 다 해준다는 것인가 ?) var myApp = angular.module('myApp', []); myApp.controller('EmailsCtrl', ['$scope', function ($scope) { $scope.emails = {}; $scope.emails.messages = [{ "from": "Steve Jobs", "subject": "I think I'm holding my phone wrong :/", "sent": "2013-10-01T08:05:59Z" },{ "from": "Ellie Goulding", "subject": "I've got..
실제 서버의 XHR 호출을 한다. $http 메소드는 Angular가 서버 데이터에 접근하는 기능을 래핑한 메소드이다. myApp.controller('MainCtrl', '$http' ['$scope', function ($scope, $http) { $http({ method: 'GET', url: '//localhost:9000/someUrl' }) .success(function (data, status, headers, config) { // 성공! 데이터를 가져왔어 }) .error(function (data, status, headers, config) { // 이런. 뭔가 잘못되었음! :( }); }]); -- GET요청을 보내고 성공인지 실패인지 확인한다. { "user": { "name..
textarea의 스크롤이 있는지 없는지 확인하는 것이 필요했다. (function($) { $.fn.hasScrollBar = function() { return this.get(0).scrollHeight > this.innerHeight(); } })($); - 스크롤의 유무를 확인하는 function을 직접 만들어줘서 사용하면 된다. fn에 대해 찾아봤는데, fn 속성은 prototype 속성의 가명이라고 한다.또한, prototype과 fn은 완전히 같은 것이라고 한다.
양방향 데이터 바인딩이란, 완전히 동기화된 데이터라고 생각하면 좋다. 모델을 갱신하면 뷰에 반영되고, 뷰를 갱신하면 모델에 반영되는 형태이다. * 동기화를 위한 다른 작업을 하지 않아도 자동으로 동기화. My model data: {{ myModel }} - view단의 에서 myModel이라는 모델을 연결. var myApp = angular.module('myApp', []); myApp.controller('MainCtrl', ['$scope', function ($scope) { $scope.myModel = ''; }]); 실제 출력 화면의 textbox에 입력해보면 My model data에 값이 바로바로 동기화되는 것을 확인할 수 있다. * 출처 : http://soomong.net/blog..
필터는 배열의 데이터와 함께 사용한다. 또한, 루프 밖에서 사용이 가능하다. 특정 조건에 만족하는 데이터만 구하고 싶을 때 사용. (예를 들어 에 입력된 값으로만 사용자를 구하고 싶을 때) 전역으로 선언 myApp.filter('reverse', function () { return function (input, uppercase) { var out = ''; for (var i = 0; i < input.length; i++) { out = input.charAt(i) + out; } if (uppercase) { out = out.toUpperCase(); } return out; } }); // 데이터를 제공하는 컨트롤러 myApp.controller('MainCtrl', ['$scope', fun..