I'm using Angular 6.
I know how to access images in the following way:
http://localhost.com:4200/assets/image.png
by putting that image on the path:
/src/assets/image1.png
but right now I'm doing a component which is on the path:
/src/app/components/mycomp
then I want to use another image2.png which is gonna be used only by this component. Then I don't want to put this image on a global directory like on the first case. Instead, I want to put that image on this location:
/src/app/components/mycomp/assets/image2.png
The goal is to make this component easily portable.
Also, on the file: mycomp.component.css I'm gonna reference that file.
Is anyway to do this?
On this project I will have many of individual components, each of them with multiple different assets and I don't want to mix all these assets. I want each component has his own space/directory.
Is anyway to achieve this?
You could solve your task by encoding your images using base64 converter (for example https://www.base64-image.de/).
If your images can be converted to SVG - you can also embed them into your templates.
Hope this will help you.
Related
I know this is very a general question but I am failing to show a file in Angular 2 after upload. Although a file is existed on folder. It showing when I restarted angular.
Source tree my project
upload folder is saving image uploaded
Have you try to empty your cache before building again ?
Images are pretty often kept in the cache, so you should have a look there.
Also you might want to create a folder that you can access easily from any component for things like images. For example if you use Angular-Cli, check the assets part.
https://github.com/angular/angular-cli/wiki/stories-asset-configuration
Well, it should be something like :
<img alt="Alternative" [src]="'./upload/yourImage.something'">
If you are trying to use the image in app.component.ts or app.component.html.
But it's pretty hard to find what's wrong since you don't show your code.
I have 4 bodymovin animations to put on a website.
Currently I am uplaoding the player with each animation/json export.
do I need to do this or can I just included the player once and then the Individual Jsons will use this player to keep file sizes down.
Kind
Regards
Ryan
You only need to load bodymovin.js once. I use angular, so I load it on init and save it as a module const, then I inject it anywhere I need. If your'e not using a framework, save it globally.
Each animation should be initiated separately using loadAnimation() and give it the container it uses. This needs to be done after the page loads because you need to find the container element.
Also, I believe the best practice is to save all JSON files on a CDN and reference them in your animation configuration .path property ant not include them in your website.
I am completely new to the Play Framework and don't consider myself too talented at front end development, so I was having a great deal of trouble with this...
I want to be able to have a button that changes an image's source back and forth. The images are rather large, so I was thinking of preloading the images in the Javascript, but in order to do that I have to access this Assets controller in order to grab the different images from the public images directory. The trouble is I am trying to keep everything neat and want to try to keep the Javascript (in my case I'm using Coffeescript) in separate files. The problem here is that I can't access this Assets controller from the Coffeescript (or any of the values passed from the Java to the template for that matter). So when I try to change the source of the image, it just gives me a 404.
There's a way in Play to create a global javascript object that has access to reverse routing for controllers, including Assets if you configure that. First read this page:
http://www.playframework.com/documentation/2.3.x/ScalaJavascriptRouting
After reading, set up your javascript routes to include this resource (see embedded router or router resource in docs):
routes.javascript.Assets.at
Then you'll be able to access assets throughout your javascript as follows:
console.log(jsRoutes);
console.log(jsRoutes.controllers.Assets.at("images/favicon.png").url);
I'm creating a new project and I want to customize the location of the generated files from Randori. How can I do this?
Check out Lesson-02: Creating an Initial HTML file & Run Configuration
From here you will see how to edit your Randori configuration. You can make the generated output anything you want. However just make sure to update your main html file and point to the correct (customized) generated folder.
One more point on this when you call the launch() method of RandoriBootstrap, you can pass two arguments. The first is whether you want debug mode on or off (debug mode does cache busting) the second is the URL that the class loader will use to find your classes. Should you put things in generatedFoo folder, you need to make sure the RandoriBootstrap knows this.
Hi,
For my project I m using jquery bulit in photo slide show,jquery code is taking images from array and displaying the images..The problem is I have a lot of images which I don't want to put it in Array(because it need manual effort) instead of that I want to read each image from the folder and display the images. the advantage of doing so is whenever you want to add more images you need to drop it in folder since you are reading images from folder so need not to do any thing in code level.so it makes your work easier and simpler.. so is there any way to achieve the same using javascript?.
Thanks in Adavance.
Javascript being client-side, it's possible to list the content of a server directory with it. You'll need some server side scripting to do that, like PHP.
see this SO question for an example
I think you should add an Ajax request to get the names of file in the directory.
After you can just pass along the array and show only those images in the slideshow.