Created
April 28, 2015 13:16
-
-
Save ianibo/65741ebde55b181fe2ca to your computer and use it in GitHub Desktop.
Smart Admin Angular Version - Adding a new "Home" screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rough notes on my first new controller inside a SmartAdmin angular apps. Documentation seems very thin on the ground, so experimenting and documenting those experiments here. | |
New dir :: public/app/home with the following files | |
module.js | |
define([ | |
'angular', | |
'angular-couch-potato', | |
'angular-ui-router', | |
'angular-resource' | |
], function (ng, couchPotato) { | |
'use strict'; | |
var module = ng.module('app.home', [ | |
'ui.router', | |
'ngResource' | |
]); | |
module.config(function ($stateProvider, $couchPotatoProvider) { | |
$stateProvider | |
.state('app.home', { | |
url: '/home', | |
views: { | |
"content@app": { | |
controller: 'HomeCtrl', | |
templateUrl: 'app/home/home.html', | |
resolve: { | |
deps: $couchPotatoProvider.resolveDependencies([ | |
// 'home/HomeCtrl' | |
]) | |
} | |
} | |
}, | |
data:{ | |
title: 'DashHome' | |
} | |
}); | |
}); | |
couchPotato.configureApp(module); | |
module.run(function($couchPotato){ | |
module.lazy = $couchPotato; | |
}); | |
return module; | |
}); | |
HomeCtrl.js | |
define(['app'], function (module) { | |
"use strict"; | |
module.registerController('HomeCtrl', function ($scope) { | |
}); | |
}); | |
home.html | |
<div id="content" ng-controller="HomeCtrl"> | |
<div class="row"> | |
<big-breadcrumbs items="['Home', 'My Home']" class="col-xs-12 col-sm-7 col-md-7 col-lg-4"></big-breadcrumbs> | |
<div smart-include="app/layout/partials/sub-header.tpl.html"></div> | |
</div> | |
Main content | |
</div> | |
<!-- END MAIN CONTENT --> | |
Updated app/includes.js and added | |
'home/module', | |
'home/HomeCtrl', | |
below Dashboard | |
Updated ./app/layout/module.js and replaced | |
// $urlRouterProvider.otherwise('/dashboard'); | |
with | |
$urlRouterProvider.otherwise('/home'); | |
To use new thing as home. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment