Sorry, here is the use of the directive:
<area:scene-button-bar integration-id="currentArea.integrationId"
max-scenes="5"></area:scene-button-bar>
David
On Wednesday, December 3, 2014 5:38:41 PM UTC-5, Frédéric Fanchamps wrote:
>
> Heu... in the code/html you have shared, you only create the directive
> areaSceneButtonBar but you don't show the usage.
> Missing something in your post?
>
> On Wednesday, December 3, 2014 9:59:00 PM UTC+1, siegeld wrote:
>>
>> I've created a directive that for some reason the link function only gets
>> called once per app lifecycle, and that the scope in the directive appears
>> shared when I route to different pages. Please see the directive code
>> below:
>>
>> lutronDirectives.directive('areaSceneButtonBar', ['LutronServerService',
>> function(LutronServerService) {
>> var linker = function(scope, element, attributes) {
>> scope.scenes = [];
>> scope.model = 0;
>> for (var i = 0; i < parseInt(scope.maxScenes); i++) {
>> scope.scenes.push({name: "Scene " + i, number: i.toString()});
>> }
>> var area = LutronServerService.getLutronArea(scope.integrationId);
>> if (area != null)
>> scope.scenes =
>> LutronServerService.getLutronArea(scope.integrationId).scenes;
>> else
>> scope.scenes = [];
>> scope.click = function(scene) {
>> LutronServerService.setAreaScene(scope.integrationId, scene);
>> scope.model = scene;
>> }
>> scope.$on('AreaEvent', function(event, obj) {
>> if (obj.integrationId == scope.integrationId &&
>> obj.actionNumber == "6") {
>> scope.deviceLevel = parseInt(obj.parameter)
>> scope.model = obj.parameter;
>> scope.$apply();
>> }
>> });
>> LutronServerService.queryAreaScene(scope.integrationId);
>> }
>> return {
>> restrict: 'E',
>> scope: {
>> integrationId: '=',
>> maxScenes: '=',
>> },
>> templateUrl: 'partials/areaSceneButtonBar.html',
>> link: linker
>> }
>> }]);
>>
>> Please also see the templateUrl here:
>>
>> <div class="btn-group">
>> <label ng-repeat="scene in scenes" class="btn btn-primary"
>> ng-model="model" btn-radio="scene.number"
>> ng-click="click(scene.number)">
>> {{scene.name}}
>> </label>
>> </div>
>>
>> You will notice that the template create a number of bootstrap radio
>> buttons.
>>
>> So - what am I doing wrong? Why doesn't the link function get run each
>> time I create a new directive?
>>
>> Very puzzled...
>>
>> Thanks,
>>
>> David
>>
>
--
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.