반응형

jquery와 angulars 같이 사용하기.

requireJS로 시작했다가 무거운거 같아서 그냥 같이 쓰는걸로 해봤다.

문법적인 문제는 발견되지 않았다. 너무 간단한 테스트라서 그럴지도.

 

AS-IS

 : index.html에 require.js와 main.js, angular.js, controllers.js 등을 녹여넣었다.

* index.html

<!doctype html>
<html lang="en" ng-app>
    <head>
        <title>jQuery+RequireJS Sample Page</title>
        <!-- This is a special version of jQuery with RequireJS built-in -->
        <script data-main="scripts/main" src="scripts/require-jquery.js"></script>
               </script>
    </head>
    <body ng-controller="PhoneListCtrl" >
        <h1>jQuery+RequireJS Sample Page</h1>
        <p>Look at source or inspect the DOM to see how it works.</p>
       
       
       
        <div id="mydiv">aaa</div>
        <p>Total number of phones: {{phones.length}} </p>
        <p>Angulars Templates - http://docs.angularjs.org/tutorial/step_02</p>

 <p>Nothing here {{'yet' + '!'}}</p>
 
 <p>1 + 2 = {{ 1 + 2 }}</p>
 
 <p class="hello">{{hello}}______</p>
    </body>
</html> 

* main.js - require.js에서 사용함. 

 require(["jquery"], function($) {
  $("#mydiv").html("Hello this is RequireJS talking");
});


require(["jquery", "jquery.alpha", "jquery.beta"], function($) {
    //the jquery.alpha.js and jquery.beta.js plugins have been loaded.
    $(function() {
        $('body').alpha().beta();
    });
});

// angular.JS, controllers.js 를 LOAD.
require(["angular"], function($) {

});
require(["controllers"], function($) {

});

* controllers.js - angular.js에서 사용 

 function PhoneListCtrl($scope) {
  $scope.phones = [
    {"name": "Nexus S",
     "snippet": "Fast just got faster with Nexus S.",
     "age": 0},
    {"name": "Motorola XOOM™ with Wi-Fi",
     "snippet": "The Next, Next Generation tablet.",
     "age": 1},
    {"name": "MOTOROLA XOOM™",
     "snippet": "The Next, Next Generation tablet.",
     "age": 2}
  ];
 
  $scope.orderProp = "age";  
  $scope.hello = "Hello, world!"; 
}

 

TO-BE

* index.html 에 다 순차적으로 호출하였다.(require.js 사용안함) 

 <!doctype html>
<html lang="en" ng-app>
    <head>
        <title>jQuery+RequireJS Sample Page</title>
        <!-- This is a special version of jQuery with RequireJS built-in -->
        <script src="scripts/angular.js" ></script>
      <script src="scripts/controllers.js"></script>
      <script src="scripts/jquery-1.5.2.min.js"></script>
      <script src="scripts/jquery.alpha.js" ></script>
      <script src="scripts/jquery.beta.js" ></script>
        <script>        
         $(document).ready(function(){
             $("#mydiv").html("Hello this is RequireJS talking");
             $('body').alpha().beta();
         });
   
        </script>
    </head>
    <body ng-controller="PhoneListCtrl" >
        <h1>jQuery+RequireJS Sample Page</h1>
        <p>Look at source or inspect the DOM to see how it works.</p>
       
       
       
        <div id="mydiv">aaa</div>
        <p>Total number of phones: {{phones.length}} </p>
        <p>Angulars Templates - http://docs.angularjs.org/tutorial/step_02</p>

 <p>Nothing here {{'yet' + '!'}}</p>
 
 <p>1 + 2 = {{ 1 + 2 }}</p>
 
 <p class="hello">{{hello}}______</p>
    </body>
</html>

 

 

 

 

 

 

반응형
반응형

 

RequireJS is a JavaScript file and module loader. It is optimized for in-browser use, but it can be used in other JavaScript environments, like Rhino and Node. Using a modular script loader like RequireJS will improve the speed and quality of your code.

 

http://requirejs.org/

 

 

프로젝트에 require.js와 main.js 파일이 필요하다.

아래에서 main.js를 호출하는 구문이다.

<script src="require.js" data-main="main"></script>

main.js( data-main="main" )에 로드할 JSLibrary와 해당 JSLabrary의 구문을 입력하면 된다.

아래에는 "jquery.js" 가 있어야 실행이 된다.

require(["jquery"], function($) {
  $(‘#mydiv”).html(‘Hello this is RequireJS talking”);
});

 

** Optimize your JavaScript with RequireJS

http://www.webdesignerdepot.com/2013/02/optimize-your-javascript-with-requirejs/

 

 

IE 6+ .......... compatible ✔
Firefox 2+ ..... compatible ✔
Safari 3.2+ .... compatible ✔
Chrome 3+ ...... compatible ✔
Opera 10+ ...... compatible ✔

Get started then check out the API.

 

require.js 2.1.4MinifiedWith Comments

All you need to start using require.js in the browser.

Sample RequireJS 2.1.4 + jQuery 1.9.1 projectDownload

A zip file containing a sample project that uses jQuery and RequireJS.

r.js: Optimizer and Node and Rhino adapterDownload

The r.js file allows you to run the optimizer as well as run modules in Node or Rhino.

If you are running in Node, and want to use npm to install this file via npm, see the Use with Node page for more information.

For information on its use, as well as how to get the JAR files to run it under Rhino, see the r.js README.

Plugins§ 2

These are useful loader plugins that have the same license terms as require.js itself. Download the plugin file and place it as a sibling to your "data-main" main.js script.

textDownload

Load text files and treat them as dependencies. Great for loading templates. The text strings can be inlined in an optimized build when the optimizer is used.

domReadyDownload

Wait for the DOM is ready. Useful for pausing execution of top level application logic until the DOM is ready for querying/modification.

cs (CoffeeScript)Download

Load files written in CoffeeScript. With this plugin, it is easy to code in CoffeeScript in the browser, it can participate in the optimizer optimizations, and it works in Node and Rhino via the RequireJS adapter. This is the best way to do cross-environment, modular CoffeeScript. The project home has more information on how to install and use it.

i18nDownload

Load string bundles used in internationalization (i18n) that are made up of separate country/language/locale-specific bundles.

반응형
반응형
마이크로소프트웨어(2013.02), 습관의 힘, 프레임

 

마이크로소프트웨어 (월간) 2월호
국내도서>잡지
저자 : 마소인터렉티브편집부
출판 : 마소인터렉티브(잡지) 2013.01.29
상세보기

 

습관의 힘
국내도서>경제경영
저자 : 찰스 두히그(Charles Duhigg) / 강주현역
출판 : 갤리온 2012.10.30
상세보기

 

프레임
국내도서>자기계발
저자 : 최인철
출판 : 21세기북스(북이십일) 2007.06.08
상세보기

반응형
반응형

단식은
생리학상 가장 중요한 신경적,
정신적 기능을 정상상태로 안정시켜
젊게 만드는 효과를 준다. 즉 신경조직은 소생되고
정신력은 개선된다. 분비선 조직과 호르몬 분비는
자극되며 촉진된다. 조직의 생화학적인
미네랄의 균형도 평준화된다.


- 김진대의《단식과 건강》중에서 -


* 단식은 강력합니다.
자신의 육체적 정신적 건강이 '리셋'되고
삶 전체에 일대 전환이 이루어질 수도 있습니다.
불치의 큰 병에 걸린 사람도 더러 살려내고,
젊고 건강할 때 하면 건강을 지켜줍니다.
1년에 한 번쯤 꼭 실천해 보십시오.
자신에게 '비움'의 선물로.

반응형

'생활의 발견 > 아침편지' 카테고리의 다른 글

얼마만의 휴식이던가?  (0) 2013.02.15
"우리는 행복했다"  (0) 2013.02.14
아버지의 포옹  (0) 2013.02.12
엄마의 기도상자  (0) 2013.02.08
황홀경은 짧다  (0) 2013.02.07
반응형

성공은 내가 주변 사람들을
얼마나 밟고 올라섰느냐에 좌우되는 것이 아니다.
오히려 주변 사람들을 얼마나 끌어올려주느냐에 달려있는 것이다.
그렇게 하는 과정 속에서 사람들은 나를 끌어올려주고
나도 그렇게 해주었다.
-조지 루카스(영화 스타워즈 감독)

 

일찍이 철강왕 앤드류 카네기는 ‘타인을 부자로 만들지 않고서는
아무도 부자가 될수 없다’고 말했습니다.
한편, 플라톤은 ‘남을 행복하게 해줄 수 있는 사람만이
행복을 얻을 수 있다’고 갈파했습니다.
먼저 타인의 행복과 성공을 도우면
자연스럽게 나의 행복과 성공이 따라옵니다.

반응형
반응형

사람들에게 일을 어떻게 처리해야 하는지 알려주지 말라. 대신 무엇을 해야 하는지 알려주라. 그로써 그들의 독창력을 키울 수 있다. - 조지 S. 패튼 장군 -

Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity. - General Geoge S. Patton -

반응형
반응형

전심을 다해 보낸 하루는 세상을 발견하는 데 충분하고도 남는 시간이다. - 제임스 러셀 로웰

One day, with life and heart, is more than time enough to fine a world. - James Russell Lowell

반응형
반응형

아버지가
팔을 뻗더니 나를 꼭 안았다.
그것은 사랑이 충만한 포옹이었다.
그 깊은 포옹은 그동안의 아버지의 마음을
전해 주었다. "네가 어떤 일을 처음으로 시작할 때,
뭔가를 성취했을 때, 그리고 기대서 울 어깨가
필요할 때 곁에 있어주지 못해서 미안하구나."
나는 껴안은 두 팔을 놓고 싶지 않았고,
아버지도 그런 것 같았다. 포옹이
그동안의 회한과 원망들을
위안과 용서로 바꾸었다.


- 잭 캔필드의《가족, 사랑할 수 있을 때 사랑하라》중에서 -


* 놀랍게도
포옹을 모르는 아버지가 많습니다.
평생 동안 아버지와 포옹 한 번 한 적이 없었다는
이야기를 많이 듣습니다. 아버지들이 포옹을
어색해 하며 피해야 할 이유가 없습니다.
아버지의 포옹은 때로 어마어마하게
큰 치유의 힘을 갖습니다.
조금도 아끼지 마세요.
아버지의 포옹.

반응형

'생활의 발견 > 아침편지' 카테고리의 다른 글

"우리는 행복했다"  (0) 2013.02.14
단식과 건강  (0) 2013.02.13
엄마의 기도상자  (0) 2013.02.08
황홀경은 짧다  (0) 2013.02.07
심장의 황홀경!  (0) 2013.02.06

+ Recent posts