javascript - Angular routes for a detailed view, using Foundation -
problem
new angular , i'm using "foundation apps: building business directory in angular. i'm looking create routes detailed view each of businesses, http://localhost:8080/nameofbusiness
.
i've been reading angular docs , this example pretty i'm trying do, i've tried using in similar snippet (see below) app.js
, doesn't seem compiling correctly.
github: https://github.com/onlyandrewn/angular
snippet
phonecatapp.config(['$routeprovider', function($routeprovider) { $routeprovider. when('/phones', { templateurl: 'partials/phone-list.html', controller: 'phonelistctrl' }). when('/phones/:phoneid', { templateurl: 'partials/phone-detail.html', controller: 'phonedetailctrl' }). otherwise({ redirectto: '/phones' }); }]);
app.js
'use strict'; var myapp = angular.module('application', [ 'ui.router', 'nganimate', //foundation 'foundation', 'foundation.dynamicrouting', 'foundation.dynamicrouting.animations' ]) .config(config) .run(run) ; config.$inject = ['$urlrouterprovider', '$locationprovider']; function config($urlprovider, $locationprovider) { $urlprovider.otherwise('/'); $locationprovider.html5mode({ enabled:false, requirebase: false }); $locationprovider.hashprefix('!'); } function run() { fastclick.attach(document.body); }
home.html (main view of businesses)
--- name: home url: / --- <div ng-controller="mainctrl"> <header> <p class="sponsored" id="top">sponsored </p> <img src="http://placehold.it/200x30" class="sponsors" alt=""> <h1>business directory</h1> <div class="find"> <input type="search" placeholder="what looking for?" ng-model="query"> </div><!-- /.find --> </header> <div class="businesses"> <div class="storeicon"> <img src="/assets/img/store.png" class="store" alt=""> </div><!-- /.storeicon --> <p class="number">search {{businesses.length}} businesses in brandon</p><button class="filter button">filter <i class="fa fa-chevron-down"></i></button> <div class="options"> <div class="cat"> <div class="categories"> <div class="group"> <p class="name">grade level</p> <div class="check"> <input type="radio" name=""><p>auto</p> <input type="checkbox" name=""><p>restaurant</p> <input type="checkbox" name=""><p>other</p> </div><!-- /.check --> </div><!-- /.group --> <div class="group"> <p class="name">school type</p> <div class="check"> <input type="checkbox"> <input type="checkbox"> <input type="checkbox"> <input type="checkbox"> <input type="checkbox"> </div><!-- /.check --> </div><!-- /.group --> </div><!-- /.categories --> </div><!-- /.cat --> </div><!-- /.options --> </div><!-- /.businesses --> <div class="all"> <div class="business large-4.columns" data-ng-repeat="business in businesses | filter:query | orderby:'name'" > <div class="overlay"> <a href=""><img src="http://placehold.it/300x300" class="storefront" alt=""></a> </div><!-- /.overlay --> <div class="info"> <a href=""><p class="name">{{business.name}}</p></a> <p class="description">{{business.description}}</p> <p class="address">{{business.address}}</p> <a href="" class="website">{{business.website}}</a> </div><!-- /.info --> </div> </div> <footer> <hr> <i class="fa fa-twitter"></i> <i class="fa fa-facebook"></i> <div class="backcontainer"> <a href="#top"><p class="back">back top</p></a> </div><!-- /.backcontainer --> </footer> </div>
expanded.html (detailed view of 1 of businesses)
--- name: expand url: /:id --- <div ng-controller="mainctrl"> <p>this expanded view each of businesses</p> </div>
you need define parent view expanded template using simplified built in plugin, foundation apps use generate proper $routeprovider's configuration. can use same plugin define wrapper controller it.
your expanded.html file may :
--- name: expand url: /:id parent: home controller: editctrl --- <p>this expanded view each of businesses</p> <pre> {{$stateparams}}</pre>
now if /#!/home
url decided parent page or product listing page, /#!/home/nameofbusiness
take it's child page "expanded", , set id value of $stateparams "nameofbusiness" $stateparams -> {"id":"nameofbusiness"}
accessible directly in expand template or within it's related controller if need build logic on top of it.
you find more details in foundation apps dynamic routing documentation
Comments
Post a Comment