タグ

2014年5月7日のブックマーク (4件)

  • AngularJSのDIの仕組み、minify対策は覚えておこう! - Qiita

    DI (Dependency Injection)ってのは日語では依存性注入とも呼ばれ、大雑把に言うとAngularJSがコントローラなどに必要とされているコンポーネント(オブジェクト)をいい感じに渡してやる機能です。 ここでは特にAngularJSのDIがどのような仕組で動いてるか、そしてその独特なDIの実装にまつわるトラブルケースを説明します。 AngularJSのコントローラの書き方 まずはAngularJSの中心的な機能であるコントローラの書き方には、簡単版と面倒版の複数の書き方があることを抑えておきましょう。 パターン1(グローバル関数パターン) サンプルとかでよく見るのは↓こういうグローバル関数の形のコントローラです。

    AngularJSのDIの仕組み、minify対策は覚えておこう! - Qiita
    d_animal141
    d_animal141 2014/05/07
    AngularJSのDIの仕組み、minify対策は覚えておこう
  • AngularJS のデータバインドを支える $watch - AngularJS Ninja Blog

    AngularJS の強力なデータバインドを支える仕組みのうち、まず $watch について取り上げる。 $watch を使えば、監視(Observe)したいオブジェクトやプロパティが変化したときに実行する処理(リスナー)を容易に記述できる。 $watch を利用する場所は scope のある directive や controller で、ng-model や ng-bind のようなデータバインドする directive を独自に実装する場合や、モデルの変更に応じて処理をバインドする場合などに使用できる。 $digest サイクル $watch による変更検知処理は、ポーリング的(一定間隔で頻繁)に実施されるのではなく、以下のイベントが生じたときに $digest サイクル(または $digest ループ)と呼ばれる処理が実行され、その中で実行される。 イベント 概要

    d_animal141
    d_animal141 2014/05/07
    AngularJS のデータバインドを支える $watch
  • CoffeeScript Tips - I/O

    即時関数の引数に別名をつける 1 2 do ($ = jQuery) -> console.log $ コンパイルすると 1 2 3 (function($) { return console.log($); })(jQuery); jQuery のプラグイン書くときとかに使う。 オブジェクトリテラルでオブジェクトを作る 1 2 3 4 a = 3 b = true c = 'bar' console.log {a, b, c} # => { a: 3, b: true, c: 'bar' } superを引数付きでコールする super()ではなくsuperと書くことで引数を引き継いでコールしてくれる。 1 2 3 4 5 6 7 class Foo constructor: (@a) -> class Bar extends Foo constructor: -> super bar

    d_animal141
    d_animal141 2014/05/07
    CoffeeScript Tips - I/O
  • Tutorial: a full Backbone.Marionette application (part 1) | Bridging the geek-suit divide

    In previous posts, I introduced you to Backbone.Marionette which provides many niceties to help you build complex Backbone.js apps. We’ll cover more advanced topics here, such as Backbone.History, modal windows, organizing code into sub applications, and more. The resulting app can bee seen live here. Let’s get started! Update (June 2013): I’ve written a book on Marionette. It guides you through d

    d_animal141
    d_animal141 2014/05/07
    Tutorial: a full Backbone.Marionette application (part 1)