how can we do that?
The problem is that ng-model is hard coded to searchStr and selectedObject is readonly.
Is there similar component for autocomplete for angular JS. Angucomplete is great because it can be connected with JSON response.
Solution
use angcomplete-alt, it has a lot of extra features and "initial-value" attribute.
Angucomplete is a component, in this you can set Initial value.
Please check below links for it.
http://ghiden.github.io/angucomplete-alt/
https://github.com/darylrowland/angucomplete
Related
I am using form.io (angular JS) to create a form using a JSON object. Also using the 'wizard' mode.
This works well, but i just cant seem to understand how to set the options for the form.
Specifically the breadcrumbSettings.clickable setting, which i need to set to false.
I am creating the form in the HTML like this:
<formio form="formCtrl.formio" submission="submission" ></formio>
I tried setting the 'options' param in the html/JS/accessing the form object. Nothing works.
And i cant find a relevant example for setting the options object using angular js.
Anyone out there knows how to achieve this?
Thanks,
Guy
As per the documentation you have to pass formio-options attribute to the above formtag.
Documentation link: https://github.com/formio/ngFormio/wiki/Formio-Directive
example: <formio src="currentForm" formio-options="{skipQueue: true}"></formio>
You would have to pass json of options applicable to formio here in formio tag.
Here some more link from documentation from official repository: https://github.com/formio/help.form.io/blob/49f570dab40edc87234cc06f4dd833aa7aa03561/_paragraphs/developer/offline/offlineapi.md#request-options
How to find and replace a specific text on a html page using AngularJs
That text is on a third party component so the id and the class is keeping changing. What I can reference is the text itself that I want to change.
That specific text on the html page is no class or id or any ng-tag around it.
I am not a angularjs developer and the page was built on asp.net mvc with the view (cshtml) using angularjs version1.
Is there a way in angularjs to find and place the text like the way in javascript:
document.body.innerHTML = document.body.innerHTML.replace('old_text', 'new_text');
Thank you!
In angularjs each application state(page) has a controller. The logic to access the Dom should placed in said controller.
To manipulate the DOM please see this answer
In Angular world, it's called data binding. Here are the official docs on data binding.
Here is the working DEMO of data being updated in time. First, html displays "Initial Text" and in 5 seconds it's changed to "New Text".
What was done for this demo:
An angular component was created with a dedicated variable $scope.text that holds text values that will change in time.
Then, this variable is used in the HTML markup, like this: {{ text }}.
Angular handles the HTML re-rendering automatically for you, so when the value of $scope.text is modified in the component, Angular forces re-rendering of the html in the browser
UPD another example with Angular two-way binding: DEMO.
Here user can change $scope.text value in the input field, which automatically changes its value in the controller. Try to edit the input field and you will see how it instantly updates in the header above the input field.
I'm wondering if it's possible to enable html-tag support in react-select.
I'm using promise callback function to inject list of suggestion, and have added <em>tag into the results..
But there's no way to tell react-select consider it as html tag.
How to do that ?
You'll want to use the optionRenderer property for this, and define a custom method that returns your element. This can contain html.
See example of this in react-select documentation.
You should handle this as a string, and use Dangerously Set innerHTML to display it in your component.
I'm using md-autocomplete to show results of an api query. Attribute md-items is iterating over a promise: item in getItems(searchText).
This is working well, and using the cache subsequent uses of the same search text return immediately with the same results.
But I need to be able to clear the cache at some points, when other search parameters change. How can I do this? By accessing the md-autocomplete controller perhaps? Although that seems non-standard and I'm not sure how.
As of version 1.0.5 of angular-material this isn't possible. I didn't find any acceptable workarounds, so I'm just disabling the cache with md-no-cache="true".
I've logged an issue for this on the angular-material project including a suggestion on how it could work.
It is definitely possible to reset the md-no-cache attribute programmatically anytime on your md-autocomplete directive.
If you have a boolean variable on your controller, let's say:
$scope.noCacheResults = false;
Then on your directive you can bind this variable to the md-no-cache attribute:
<md-autocomplete ...
md-no-cache="noCacheResults">
</md-autocomplete>
Like this, whenever your search parameters change you can set the $scope.noCacheResults to true or false depending whether you want to keep caching the query results or not.
Something that worked for me. Put an ng-if on your autocomplete. Then, in the code that changes the value of the other fields affecting this field, set that value to false, and then within a timeout, set it to true again. This will effectively remove the item from the DOM and put it back all nice and new with no cache.
I want to let the user crop an image, I found this JQuery plugin - http://deepliquid.com/content/Jcrop.html
I tried to use it with Angular-ui's Jquery passthrough option, adding the ui-jq=Jcrop directive to the <img>
The problem is that If I use ng-src to dynamically change the image it doesn't work and nothing is seen. If I change it to src and put a static url I can see the image and Jcrop.
how can I fix that ?
also, how can I listen to Jcrop's callbacks to know what is the user's selection ?
is there a better / simpler way to add image cropping functionality to AngularJS ?
Here is my solution:
I've written a directive that create img element and apply plugin on it. When src is changed, this img is removed and content that was created by plugin is also destroyed and then re-created new img with new src and again applied plugin on it.
Also provided 'selected' callback to be able to get coordinated that were selected (wrapped in $apply so you can modify your scope values in it).
Check my solution at Plunker
I've built a demo using AngularJS and Jcrop here:
Demo: https://coolaj86.github.com/angular-image-crop
On Github: https://github.com/coolaj86/angular-image-crop
You can leverage ui-event to create an event definition object with the keys being the event names and the values being the callbacks. Or you can simply pass these events as options to Jcrop (according to the documentation)
Finally, there is a new update coming to ui-jq that lets you add ui-refresh which is an expression to be watched to re-trigger the plugin.
Theoretically you should be able to do
<img ui-jq="Jcrop"
ui-options="{onSelect:myCallback}"
ui-event="{onChange:'myCallback($event)'}"
ui-refresh="imgSrc"
ng-src="imgSrc" />
Note: this simply re-fires the passthrough again, and doesn't automatically mean this will fix the problem or that the plugin will behave properly when re-initialized
We're still working on a good way to allow you to trigger different events at different times.