{"id":240,"date":"2015-04-20T22:40:14","date_gmt":"2015-04-20T22:40:14","guid":{"rendered":"https:\/\/www.tech.shinynewthings.com\/?p=240"},"modified":"2015-04-20T22:40:14","modified_gmt":"2015-04-20T22:40:14","slug":"angularjs-configuration-file-app-config-js","status":"publish","type":"post","link":"https:\/\/www.tech.shinynewthings.com\/?p=240","title":{"rendered":"AngularJS Configuration File &#8211; app.config.js"},"content":{"rendered":"<p>&#8216;use strict&#8217;;<\/p>\n<p>angular.module(&#8216;interceptcms&#8217;)<\/p>\n<p>\/\/ USED TEMPORARILY FOR TRACKING STATE CHANGE<br \/>\n\/\/ STATE CHANGE SUCCESS ISN&#8217;T BEING CALLED<br \/>\n.run(function($rootScope) {<br \/>\n  $rootScope.$on(&#8220;$stateChangeSuccess&#8221;, function(event, toState, toParams, fromState, fromParams) {<br \/>\n    if (fromState.name === &#8220;&#8221;) {<br \/>\n      \/\/ The initial transition comes from &#8220;root&#8221;, which uses the empty string as a name.<br \/>\n      \/\/console.log(&#8220;initial state: &#8221; + toState.name);<br \/>\n    } else {<br \/>\n      console.log(&#8220;NEW state: &#8221; + toState.name);<br \/>\n    }<br \/>\n  });<br \/>\n})<\/p>\n<p>\/\/ NOTE &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n\/\/ THE CREATE STATE REUSES THE EDIT VIEW FOR ALL MODELS<br \/>\n\/\/ IF TEMPLATES NEED TO BE SEPARATE CHANGE<br \/>\n\/\/ the create objects templateUrl property<br \/>\n\/\/ in app.routes.js<\/p>\n<p>.constant(&#8216;RESOURCES&#8217;, (function() {<br \/>\n  \/\/ Define your variable<br \/>\n  var HOSTNAME = window.location.hostname;<br \/>\n  \/\/ Use the variable in your constants<br \/>\n  return {<\/p>\n<pre><code>\/\/ HOSTNAME\nHOSTNAME: HOSTNAME,\n\n\/\/ APPLICATON NAME USED IN HEADER\nAPP_NAME: \"Online Publications\",\n\n\/\/ URLS\n\n    \/\/ FRONTEND APP\n    APP_URL: \"http:\/\/\" + HOSTNAME + \":9000\/\",\n\n    \/\/ AUTHORIZATION APP\n    AUTH_URL: \"http:\/\/\" + HOSTNAME + \":3000\/\",\n\n    \/\/ DATA FEED\n    API_URL: \"http:\/\/\" + HOSTNAME + \":1337\/\",\n\n    \/\/ NOTIFICATIONS SERVER\n    SOCKETIO_SERVER: \"http:\/\/\" + HOSTNAME + \":3000\/\",\n\n\/\/ DIRECTORIES\n\n    \/\/ DEFAULT VIEWS FOLDER\n    VIEWS: '\/views\/',\n\n    \/\/ USED IF FEATURE NESTING IS TRUE\n    COMPONENTS: \"\/components\/\",\n\n    \/\/ CONTROLLERS\n    CONTROLLERS: \"..\/controllers\/\",\n\n\n\/\/ VIEWS EXT\nVIEW_EXT: '.html',\n\n\n\/\/ USED IF FEATURE NESTING IS FALSE \/ AND URLS ARE AUTO GENEREATED\nDEFAULTS: \"defaults\",\n\n\n\/\/ STATE DEFINITIONS \/ URL PARTIALS \/ ACTIONS\n\n    \/\/ CREATE URL AND FILE REFERENCE FOR EACH MODEL\n    CREATE: \"create\",\n\n    \/\/ LIST URL AND FILE REFERENCE FOR EACH MODEL\n    LIST: \"list\",\n\n    \/\/ VIEW URL AND FILE REFERENCE FOR EACH MODEL\n    VIEW: \"view\",\n\n    \/\/ EDIT URL AND FILE REFERENCE FOR EACH MODEL\n    EDIT: \"edit\",\n\n    \/\/ SEARCH STRING DELIMITER\n    SEARCH: \"search\",\n\n\n\/\/ A LIST OF FIELDS FOR ALL MODELS THAT ARE FOR INTERNAL \/ CMS USE ONLY\nRECORD_KEEPING_DATA: ['id', 'createdAt', 'createdBy', 'updatedAt', 'updatedBy'],\n\n\/\/ A LIST OF FIELDS FOR ALL MODELS THAT ARE FOR INTERNAL \/ CMS USE ONLY\nCTRLS: ['DefaultCtrl', 'TagtypesCtrl', 'TagCtrl'],\n\n\/\/ DEFAULT_IMG REFERENCE FOR EACH MODEL\nDEFAULT_IMG: \"http:\/\/placehold.it\/400x300\",\n\n\/\/ ARRAY of Controllers with additional \/ static \/ custom routing needs\n\/\/ CREATE AN ARRAY OF OBJECTS WITH STATE, CTRL and FEATURENESTING PROPERTIES\n\/\/ ex: [{ state:'essay', ctrl:\"EssaysCtrl\", featureNesting: false }]\nSTATECTRLS: [],\n\nLIMIT: 20,\n\nDIR: \"desc\"\n<\/code><\/pre>\n<p>};<br \/>\n})());<br \/>\n\/*<br \/>\n\/\/ AUTO GENERATED ROUTING<br \/>\n\/\/ **** REQUIREMENTS ****<\/p>\n<p>\/\/ STATE MUST MATCH<br \/>\n\/\/ API MODEL\/CLASS NAME<br \/>\n\/\/ ex. car<\/p>\n<p>\/\/ VIEW MUST BE NAMED<br \/>\n\/\/ state-constant VIEW_EXT<br \/>\n\/\/ ex. car-edit.html<\/p>\n<p>\/\/ MODEL DEFINITION<br \/>\n\/\/ MUST BE AVAILABLE FROM<br \/>\n\/\/ API_URL\/state\/model<br \/>\n\/\/ ex. localhost:33777\/car\/model<\/p>\n<p>.constant(&#8216;STATECTRLS&#8217;, [<br \/>\n\/\/      { state:&#8217;essay&#8217;, ctrl:&#8221;EssaysCtrl&#8221;, featureNesting: false },<br \/>\n\/\/      { state:&#8217;tag&#8217;, ctrl:&#8221;TagsCtrl&#8221;, featureNesting: false },<br \/>\n\/\/      { state:&#8217;tagType&#8217;, ctrl:&#8221;TagtypesCtrl&#8221;, featureNesting: false }<br \/>\n        ]<br \/>\n    );<\/p>\n<p>*\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8216;use strict&#8217;; angular.module(&#8216;interceptcms&#8217;) \/\/ USED TEMPORARILY FOR TRACKING STATE CHANGE \/\/ STATE CHANGE SUCCESS ISN&#8217;T BEING CALLED .run(function($rootScope) { $rootScope.$on(&#8220;$stateChangeSuccess&#8221;, function(event, toState, toParams, fromState, fromParams) { if (fromState.name === &#8220;&#8221;) { \/\/ The initial transition comes from &#8220;root&#8221;, which uses the empty string as a name. \/\/console.log(&#8220;initial state: &#8221; + toState.name); } else { console.log(&#8220;NEW [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-240","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts\/240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=240"}],"version-history":[{"count":1,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts\/240\/revisions"}],"predecessor-version":[{"id":241,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts\/240\/revisions\/241"}],"wp:attachment":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}