the thing i did come up with for now is using it with a dynamic template:
element.html("<div id='" + scope.model.markupId + "'></div>").show();
$compile(element.contents())(scope);
scope.api.updateGauge = function(value, max){
scope.gauge.refresh(value, max)
}
console.log("childid: " + element[0].children[0].id)
scope.gauge = new JustGage({
id: element[0].children[0].id,
value: scope.model.value,
min: scope.model.min,
max: scope.model.max,
title: scope.model.title,
label: scope.model.label,
relativeGaugeSize: true,
donut: scope.model.donut
});
then it works, is that the right/only way to do it?
On 22 August 2014 14:31, Johan Compagner <[email protected]> wrote:
> Hi,
>
> lets say i want to wrap this: http://justgage.com/ in a angular component
> so i create a nice directive:
>
> .directive('JustGage', function() {
> return {
> restrict: 'E',
> scope: {
> },
> controller: function($scope, $element, $attrs) {
> $scope.markupId = //something dynamic, uniek on the page.could also be
> given into the scope or attributes.
> },
> link: function(scope, element, attrs) {
> console.log("childid: " + element[0].children[0].id)
>
>
> scope.gauge = new JustGage({
> id: element[0].id,
> value: scope.model.value,
> min: scope.model.min,
> max: scope.model.max,
> title: scope.model.title,
> label: scope.model.label,
> relativeGaugeSize: true,
> donut: scope.model.donut
> });
> },
> template: '<div id="{{markupId}}"></div>'
>
> };
> })
>
> that childid will print: {{markupId}}
>
> because i need to wait even 1 more digest cycle before i can do new
> JustGage (because only then that element has the right id)
>
> How to fix this nicely? If you include 3th party libs that want to bind on
> an id. And if that id is dynamic what is the event/time to really know, ok
> now it is done, now you can do what you want.
>
> johan
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "AngularJS" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/angular/CoSQZIwO2Os/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>
--
Johan Compagner
Servoy
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.