In this post we are going learn how to copy to clipboard in AngularJS application using ngclipboard js plugin. I provide very simple example using CDN, so you can simply run and understand well.
when require to give function of copy some text by clicking on button or any link. There are several library can do copy text using flash player, but in this example i will do it without using flash player. In this example we will use
ngclipboard.js AngularJS Plugin for copy to clipboard.
Now i am going to share with you full example of ngclipboard js plugin. I use cdn for jquery and ngclipboard js .....
I always post small example of AngularJS function, In this example we learn how to render our HTML code in ng-repeat using trustashtml filter.
Sometimes we have array or object of records with html values, at that time we require to use ng-repeat, But we can't simple way render html code, we should require to use trustashtml or ng-bind-html-unsafe etc. So in this example i created one filter for this task using sce trustashtml. filter as like bellow you can see code of that filter using $sce.trustAsHtml.
<pre class="prettyprint lang-html">
Sometimes, we require to scroll on specific element or div on angularjs application like scroll for go on specific comment, scroll on specific table row it. However we can do it using anchorscroll in angularjs application.
anchorscroll() will help to scroll on specific "anchor" div id. anchorscroll() is provided by angularjs. We can use it simply. We don't require to write login on code jquery, because it is easy to do using anchorscroll(). $anchorScroll will use with $location variable hash.
I gave you full example of how to scroll on specific element on angularjs page, We can use simple as.....
When i was working on my Laravel angularjs application, i require to make array from comma separated string, I was not expert in angularjs so i was thingking how is it possible ?, But Finally i was found solution using custom angularjs Filter.
So, In this example, I will give you full example of how to convert comma separated string into array and how to print it. We will create array using split() of jquery. But if you know angularjs we can't do it anything directly from layout, So we should create our custom filter, as bellow you can see i created "customSplitString" filter.
Sometimes, We may require to make to show read more and read less functionality in our AngularJS application. We can make read more using AngularJS Directive.
So, In this example i going to give you full example of read more text example. I used "dd-text-collapse" Directive for after some text it will return "..." OR "(more)" etc that as you want. You can simply customize this Directive. You can also make toggle read more and read less using this Directive.
First, you can see bellow code of just Directive, i give you bellow code of Directive, you can use direct in your AngularJS application......
Sometimes we require to display message conversion in your angularJS App, But if you are using textarea for write comment or something then text display on same like without line break. But we can display text with likebreak using nl2br(). we can use directly in nl2br() if we work on PHP But if we work on angulaJS then we can't use it directly Because it is not pre-define function.
So, we require to make custom helper or something, So in this example i created custom angular filter for nl2br, that way we can use it globally in angularJS app. we will use nl2br filter add like as bellow :
We always require to check image is exists or not in given path, If not exists then we have to set default image. If we work on PHP or any framework then we check condition or something else for image exists of not to check But If you are working on AngularJS framework then we can do it using "directive".
AngularJS directive through we can simple check image is exists or not on the given url path. In this example i use ng-src and err-src attribute to manage image, directive will check ng-src url image is exists or not, if not then it will set err-src image as default.
So, I give you very bas.....
Sometimes, we require to set value of input box from js code, But if you bind with ng-model of angular then you can't set value directly with "val()" of jquery. As Bellow example:
But of you set this way then it will display in your text box layout, but you can't get from on submit function. So, you have to also trigger input that way AngularJS can get on controller method.
You can see bellow full example that way you can understand how to solve this issue:
<pre class="prettyprint lang-html">
Today, i am going to show you how to call angular function in your js file. Sometimes we need to call angular controller function in our jquery code because we can make single function in all project.
It is very simple post but it important because many times we require to call angularjs function from jquery.
So, i given bellow example will help you how to call angularjs function in jquery. It is from scratch that way you can simply understand.
In this example i created one function "$scope.makeAlert()" In my AngularJS controller. This function have one argument that way we can also pass a.....
If you work on AngularJS web application using angular route then you notice one thing. If you click on any hyper links it makes like as bellow:
I mean always "#" will be there, But when we live this web application then it should delete "#" from URL, because it makes issue when we share link on facebook or etc.
But should look likes:
But we can remove easily using "$locationProvider.html5Mode(true);". Yo.....