Include .js in dashboard single page
Permalink
Hello,
I'm writing a package for C5.7 and in a particular dashboard single page I'm gonna build an Angular app. I could use the following code in my_angular_single_page.php:
But is there a better and more proper way to do this?
I'm writing a package for C5.7 and in a particular dashboard single page I'm gonna build an Angular app. I could use the following code in my_angular_single_page.php:
<?php echo URL::to('/packages/my_package/js/angular.min.js') ?>
But is there a better and more proper way to do this?
Yup there is. Register assets in the on_start function and require the asset in your (view) function! See the code below
Thanks, this seems to include the javascript files, unfortunately this seems to break my angular app because the libraries are included at the end of the page. Is it possible to tell concrete to include the javascript files in the header of the page?
@hawkagent
The register() method takes an $args array for setting asset position.
register( string $assetType, string $assetHandle, string $filename, array $args = array(), boolean $pkg = false )
http://www.concrete5.org/api/source-class-Concrete.Core.Asset.Asset...
Try this
The register() method takes an $args array for setting asset position.
register( string $assetType, string $assetHandle, string $filename, array $args = array(), boolean $pkg = false )
http://www.concrete5.org/api/source-class-Concrete.Core.Asset.Asset...
Try this
$al->register('javascript', 'some-identifier-name', 'js/angular.min.js', array('version' => '1.0', 'position' => Asset::ASSET_POSITION_HEADER, 'minify' => true, 'combine' => false), 'your_package_handle');