angularjs - Is this the correct use for a Directive? -


i have been tasked setting initial application structure large angular application, came across few blog posts said should directive (which agree with) have feeling have took idea far..

what have got - when navigate portal ui-router load portal template templates folder, that's inside actual template <portal-view></portal-view.. portalview directive entire view wrapped in directive.

route

angular.module('portal').config([ '$stateprovider', '$urlrouterprovider', function ($stateprovider, $urlrouterprovider) {     $stateprovider.state('portal', {         url: "/",         templateurl: "templates/portal.tpl.html"     }); }]); 

portal.tpl.html

<div class="container"> <portal-view></portal-view> </div> 

portalview directive

angular.module('portal').directive('portalview', function() { return {     controller: 'portalcontroller',     controlleras: 'vm',     templateurl: "/directives/portalview/portalview.tpl.html" }}); 

portalview folder

  • portalview
    • portalview.controller.js
    • portalview.js
    • portalview.less
    • portalview.tpl.html

in head seems idea can becoming chore when start adding more view application hoping angular pro tell me best way :)

any help, advice , links appreciated!

componentizing view , putting directive looks smart idea me. ease migration router if takes place.

portal.tpl.html unnecessary if plan follow practice, template: '<portal-view></portal-view>' enough. don't reject if have plans on using template css , js asset loading (using scripts in templates isn't straight-forward, possible), fit scheme quite well.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -