angular-vfremote コードリード

イシュー

  • angular x visualforceのよさげなサンプルなのでコードリーディングしてみる

参考

ng-controller はどこ?

  • app/js/app.js
var myModule = angular.module('angvfr', ['angvfr.controllers',
                                         'angvfr.directives',
                                         'angvfr.filters',
                                         'angvfr.services']);

// Declare app level module which depends on filters, and services
myModule.
  config(['$routeProvider', function($routeProvider) {
    $routeProvider
        .when('/',      {templateUrl: sitePrefix+'/angular_vfremote_home', controller: 'MyCtrl1'})
        .when('/view1', {templateUrl: sitePrefix+'/angular_vfremote_partial1', 
                         controller: 'MyCtrl1'})
        .when('/view2', {templateUrl: sitePrefix+'/angular_vfremote_partial2', 
                         controller: 'MyCtrl2'})
        .otherwise({redirectTo: '/'});
  }]);

configブロック

  • モジュールのロード時に実行

参考

$routeProvider

  • ルートを設定するために使用
  • when(path, route);
    • Adds a new route definition to the $route service.
  • route には、「controller」「controllerAs」「template」「templateUrl」を指定できる
    • templateUrl には、HTMLテンプレートへのパスを返す関数を設定する

参考

感想

  • Visualforceページをテンプレートとして読み込めるのはいいかも