(function () { 'use strict'; app.PageCtrl = PageCtrl; angular.module('app.controller').controller('PageCtrl', PageCtrl); PageCtrl.$inject = ['$scope', '$stateParams', 'cfg', 'item']; function PageCtrl($scope, $stateParams, cfg, state) { cfg.debug && console.log('PageCtrl', state, $stateParams); var re = /\{([\w\d_-]+)\}/g; var fn = function (match, key) { if ($stateParams.hasOwnProperty(key)) { return (null == $stateParams[key]) ? '' : $stateParams[key]; } cfg.debug && console.warn('PageCtrl: unknown state param "' + key + '"'); return ''; }; var attr, name; state = angular.copy(state); if (state.data && (attr = state.data.attr) && angular.isObject(attr)) { for (name in attr) { if (attr.hasOwnProperty(name)) { attr[name] = attr[name].replace(re, fn); } } } $scope.state = state; } })();