I'm using angular-google-map.I wanted to add custom directive( other than agm specified directive) to show tooltip on hover of polylines.
I tried applying custom directive but no effects are shown in the map.tooltip for normal html like select,h4 works.
please tell me whether we can apply custom directive or not.if yes then how.Below is my code
<agm-map [latitude]="lat" [longitude]="lng" [scrollwheel]="false" [zoom]="zoom" [styles]='mapStyles'>
<ng-container>
<agm-marker-cluster
imagePath="https://raw.githubusercontent.com/googlemaps/v3-utility-library/master/markerclustererplus/images/m">
<agm-marker *ngFor="let m of markers; let i = index" (markerClick)="clickedMarker(m.label, i)"
[latitude]="m.lat" [longitude]="m.lng" [label]="{color: 'white', text: m.title}"
[markerDraggable]="m.draggable" [iconUrl]="m.icon" (dragEnd)="markerDragEnd(m, $event)">
</agm-marker>
</agm-marker-cluster>
<agm-polyline (lineMouseOver)="clickedLine(i,polyline.data)" *ngFor="let polyline of polylines;let i = index;"
[strokeColor]="polyline.color" tooltip="this is is tooltip" >
<agm-polyline-point *ngFor="let point of polyline.path" [latitude]="point.latitude"
[longitude]="point.longitude">
</agm-polyline-point>
</agm-polyline>
</ng-container>
</agm-map>
No, because agm-polyline is not a component, it's a directive, even though it looks like an html element. This means that there is no host to bind the directive to.
Related
(I'm new to Svelte so it is quite likely that I'm doing something wrong here)
UPDATE: I've added a second, slightly different REPL which may demonstrate the problem better. Try this one: https://svelte.dev/repl/ad7a65894f8440ad9081102946472544?version=3.20.1
I've encountered a problem attempting to bind a text input to a reactive value.
I'm struggling to describe the problem in words, so hopefully a reduced demo of the issue in the attached REPL will make more sense.
https://svelte.dev/repl/6c8068ed4cc048919f71d87f9d020696?version=3.20.1
The demo contains two custom <Selector> components on a page.
The first component is passed two string values ("one" and "two"):
<Selector valueOne="one" valueTwo="two"/>
Clicking the buttons next to the input field sets selectedValue to one of these values.
This, in turn, triggers the following reactive declaration to update:
$: value = selectedValue
The input field is bound to this reactive value:
<input type="text" bind:value>
So clicking the "One" button sets the input text to "one", and clicking the "Two" button sets the input field to "two".
Importantly though, you can still type anything into the input field.
The second component is passed two array values:
<Selector valueOne={[1, "one"]} valueTwo={[2, "two"]}/>
Again, clicking the buttons sets selectedValue to one of these.
However this time the reactive declaration depends on an array element:
$: value = selectedValue[1]
Everything works as before, except now you can no longer type into the input field at all.
So the question is - why does <input bind:value> behave differently for these two:
$: value = aString
vs
$: value = anArray[x]
It seems that this is only an issue when using two-way bindings.
By switching to a one-way and an on:input handler, the problem goes away:
i.e. instead of this:
<input type="text" bind:value={valX}/>
use this:
<input type="text" value={valX} on:input={e => valX = e.target.value}/>
I'm pretty sure your reactive declaration is overwriting your bound value as soon as it changes, which is with every key stroke on the input and every button press. Meaning it technically is working, you're just reverting it each time it changes. Check out this version of it that uses a watcher.
Also binding to a reactive declaration means you're never actually changing the variables with the input (which you can see in your JSON result on the first selector when you type in the input the value doesn't update only on button click).
Why not lose the reactive declaration and bind directly to the variable you want. Then use an {#if} block to switch between which version of the input you're showing based on the truthiness of index?
<script>
export let valueOne;
export let valueTwo;
export let index;
let selectedValue = index? [] : '';
let selectValue = (val) => selectedValue = val;
</script>
{#if index}
<input type="text" bind:value={selectedValue[index]} placeholder="Type anything...">
{:else}
<input type="text" bind:value={selectedValue} placeholder="Type anything...">
{/if}
<button on:click={() => selectValue(valueOne)}>One</button>
<button on:click={() => selectValue(valueTwo)}>Two</button>
<p>
<strong>Selected value:</strong> {JSON.stringify(selectedValue)}
</p>
By binding directly to the selectedValue or an index of it you have the added benefit of changing the value with the input. Here's a working example in the REPL
I am using popover directive to display popover. I have multiple pop over in my code.
But as per requirement, we need to show only one pop up open at one time.
After googling, I found that we can use $uibTooltipProvider.option (popover-mode : single). But I am not sure how to use this inside my code.
I am using angular 1.5 with typescript.
My pop over code is as follows:
<span class="invoke-popup " popover-placement="left "
uib-popover-template="$ctrl.dynamicPopover.templateUrl"
popover-is-open="$ctrl.isPopOverOpen[$index] ">
</span>
If you want to config your tooltips on a global scale, you should do it inside the .config() function, there you can inject the $uibTooltipProvider.
angular.module('myApp').config(function($uibTooltipProvider) {
$uibTooltipProvider.options({
'property' : 'value'
});
});
There you can pass properties that will affect all you tooltips. So you can try there.
Although I'm not sure how popover-mode works exactly!
I'm trying to call a variable inside quotes inside a data-sly-template call. I would expect the output to include my string with the appropriate varible inside quotes. Below is the template and the string I'm using to call it:
Template:
<!-- template -->
<template data-sly-template.bnrButton="${ # style='String: button color class (default btn-primary)', classes='String: additional component button classes', text='String: button text (translation key)', defaultText='String: default button text (translation key)', link='String: link target for button (# is default)', fullWidth='Boolean: whether to display button in full width of container', noFollow='Boolean: if button should have a nofollow tag (no is def)', gaCategory='String: GA Category', gaEvent='String: GA Event', gaLabel='String: GA Label', gaAction='String: GA Action'}">
<a class="btn ${style || 'btn-primary'} hidden-print ${classes}${fullWidth ? ' btn-full-width' : ''}" role="button" href="${link || '#'}" rel="${noFollow ? 'nofollow' : ''}" onclick="${gaEvent # context = 'scriptString'}">${text || defaultText # i18n}</a>
</template>
<!-- call made to the template -->
<sly data-sly-call="${patterns.bnrButton # style='btn-secondary-light', classes='btn-sm', text=teaser.libraryButtonHeading, defaultText='View Library', link=teaser.myLibraryLink.href, fullWidth='true', newWindow='false', gaEvent='trackEvent('Test 1','Test 2','${teaser.teaserMessage}')'}"></sly>
If tried a number of combinations to get teaser.teaserMessage to print the authored message, but have been having issues because the patterns call is already inside quotes. I want to be able to pass a single string (called in the template call) to the template that includes all the information it needs for the onclick.
Thoughts?
Thank you.
You can use data-sly-test.variable_name before the template call to store the value into a variable:
<sly data-sly-test.gaEvent="${'trackEvent('Test 1','Test 2','{0}')' # format=teaser.teaserMessage}"
data-sly-call="${patterns.bnrButton # ..., gaEvent=gaEvent }"></sly>
The md-autocomplete provides a class named md-not-found in the md-virtual-repeat-container when you are trying to search for an element that does not exist in the dropdown, displaying an error message underneath. When you remove focus from the input element, the md-not-found is removed. The autocomplete therefore gives a false impression of having a valid input, as the user is not presented with any feedback.
Is there any way to keep the class "md-not-found", even after you unfocus the input element?
md-autocomplete official demo: https://material.angularjs.org/latest/demo/autocomplete
Update
I have made a temporary solution:
<label class="{{selectedItem !== null || searchText === '' ? '' : 'label-error'}}">Name</label>
The label-error class applies a red color.
The solution is not an answer to the question per se, but offers an alternative quick fix
I used md-autocomplete inside the md-chips and its working as well as you want.
When request return noContent(204) md-not-found is being visible and it isn't disappear until user start texting again.
<md-content layout="column">
<md-chips
class="md-input"
ng-model="myItem"
md-autocomplete-snap
md-on-add="change()"
md-on-remove="change()"
required
md-require-match="true"
md-transform-chip="reformr($chip)"
md-separator-keys="keys">
<md-autocomplete md-selected-item="selectedItem"
md-no-cache="true"
md-search-text="search.text"
md-items="item in getSuggestedItems()"
md-item-text="item.name"
md-min-length="0"
placeholder="{{ 'textItemName' | translate }}"
required
md-input-name="suggestedItem"
md-search-text-change="listSuggestedItems(search.text)">
<span md-highlight-text="search.text" md-highlight-flags="^i">{{item.name}}</span>
<md-not-found>
{{'no_item_found' | translate}}
</md-not-found>
</md-autocomplete>
</md-content>
Update 2: A The following repo on github shows the problem.
Update 1: Calling #firstNode in Template.editor.rendered returns <div class="editor"></div>.
I have the following template:
<template name="editor">
<div class="editor">
{{#each objects}}
<div class="object">{{content}}</div>
{{/each}}
</div>
</template>
The data is provided by iron-router in the data callback.
The coffeescript for my template:
Template.editor.rendered = ->
#findAll('.object').draggable()
When I go into my browser and try to drag one of the objects I get the text selection cursor and begin to select the text with the div instead of the object being dragged. So what is wrong and how can I get the drag and drop to work?
The drag and drop functionality is being provided by jquery-ui. Which is installed as a smart package.
Also feel free to edit the title of this post as I had a tough time coming up with one that made sense
The solution I found was to abstract <div class="object">{{content}}</div> into a seperate template like so:
<template name="object">
<div class="object">{{content}}</div>
</template>
Then change
Template.editor.rendered = ->
#findAll('.object').draggable()
to
Template.object.rendered = ->
#findAll('.object').draggable()
As stated in meteorpedia.