2016-09-07T20:33:38Z
To start viewing files in Angular, follow these simple steps to get started. Once you're up and running, visit the API documentation to learn how to get the most out of it.
Download view-file-ng.js (minified version) and put it with your other scripts. Alternatively, you can use Bower to install it automatically:
Or if you prefer bleeding edge:
If not using Bower, you'll also need to fetch yourself:
Load view-file-ng.js and dependencies into your HTML page (typically in the end of the BODY of your HTML):
<script src="/bower_components/highlightjs/highlight.pack.js"></script> <script src="/bower_components/angular-highlightjs/build/angular-highlightjs.js"></script> <script src="/bower_components/x2js/xml2json.min.js"></script> <script src="/bower_components/angular-x2js/dist/x2js.min.js"></script> <script src="/bower_components/ng-json-explorer/dist/angular-json-explorer.js"></script> <script src="/bower_components/vkbeautify-wrapper/dist/vkbeautify.0.99.00.beta.js"></script> <script src="/bower_components/angular-sanitize/angular-sanitize.js"></script> <script src="/bower_components/angular-recursion/angular-recursion.js"></script> <script src="/bower_components/videogular/videogular.js"></script> <script src="/bower_components/videogular-controls/vg-controls.js"></script> <script src='/bower_components/view-file-ng/dist/view-file-ng[.min].js'></script>
Note: You can simplify this by making use of wiredep, optionally together with gulp-useref.
Load view-file-ng.css into your HTML page (typically in the end of the HEAD of your HTML):
<link rel="stylesheet" href="/bower_components/highlightjs/styles/github.css" /> <link rel="stylesheet" href="/bower_components/ng-json-explorer/dist/angular-json-explorer.css" /> <link rel="stylesheet" href="/bower_components/videogular-themes-default/videogular.css" /> <link rel="stylesheet" href="/bower_components/view-file-ng/dist/view-file-ng[.min].css">
Note: You can simplify this by making use of wiredep, optionally together with gulp-useref.
Make your application module depend on the view-file-ng
module:
Expose files configuration in your Angular controller:
MyCtrl.$inject = ['$scope']; function MyCtrl($scope) { var ctrl = this; ctrl.files = [{ uri: 'https://grtjn.github.io/view-file-ng/data/sample-music.mp3', type: 'audio/mpeg' },{ uri: 'https://grtjn.github.io/view-file-ng/data/quickstart.html', type: 'text/html' },{ uri: 'https://grtjn.github.io/view-file-ng/data/bower.json', type: 'application/json' },{ uri: 'https://grtjn.github.io/view-file-ng/data/installation-guide.pdf', type: 'application/pdf' },{ uri: 'https://grtjn.github.io/view-file-ng/data/install.txt', type: 'text/plain' },{ uri: 'https://grtjn.github.io/view-file-ng/data/Video%20Sample%201%20%28Small%29.m4v', type: 'video/mpeg' },{ uri: 'https://grtjn.github.io/view-file-ng/data/Atom_Example.xml', type: 'application/atom+xml' }]; }
Add a <view-file>
element in your template like so:
<div ng-repeat="file in ctrl.files"> <view-file uri="file.uri" type="file.type"></view-file></div>