Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Any ways to improve directive without complete re-write?
Message
From
11/07/2017 07:33:18
 
General information
Forum:
AngularJS
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01652591
Message ID:
01652604
Views:
40
>Hi everybody,
>
>We have a directive written a while ago by one of the contractors who is no longer working with us. I'm afraid there is no way to fix that directive the way I want, but may be you can find a way?
>
>The directive starts with the
>
>
>app.directive('descType', [function () {
>        return {
>            restrict: 'E',
>            transclude: true,
>            replace: true,
>            scope: {
>                title: '@',
>                message: '@',
>                param: '@',
>                selected: '=',
>                description: '=',
>               
>                descrip: '=',
>                type: '=',
>                doSearch: '&',
>                filterBy: '@?'
>            },
>
>Please, note the transclude and replace options.
>
>The template for the directive is the following:
>
>
><input type="submit" value="" id="btnChoose" style="width: 100% !important; margin-top: 0;"
>           class="btn_file_select" ng-click="click()" />
>
>and this is an example of using this directive in a page:
>
>
><data-desc:type title="{{ '@String.Format(Labels.selectX, Labels.layout)'}}" do-search="popup()"
>                                            value="{{currentItem['t'+n+'LayoutId'] == 0 ? '@String.Format(Labels.selectX, Labels.layout)' : currentItem['t' + n + 'Layout']}}"
>                                            param="layouts" message="@String.Format(Labels.selectX, Labels.layout)"
>                                            filter-by="Ticket"
>                                            selected="currentItem['t'+n+'LayoutId']" descrip-value="descrip" type-value="lTypeId"
>                                            description="currentItem['t'+n+'Layout']">
>                            </data-desc:type>
>
>I would love to improve this directive. Say, add ability to delete chosen layout (because right now once something is selected, there is no way to remove that selected Layout Id). I also would like to add ability to go directly to the selected layout to edit it.
>
>The problem is - I don't see a way to introduce anything extra in the current template. Say, if I add a div around the input and add a new button to remove selected layout, it would not work at all.
>
>Do you see my dilemma? Is there a way out or I should assume that there is no way to improve the directive as it's written and I would have to fix in the pages if I'd like to introduce clearing of selected layout?
>
>Thanks in advance.

Bit rusty on directives so may be missing something but I don't see what your problem is. Can you explain a bit more.
Also don't know why transclude is true since there's no ng-transclude directive in the template ?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform