Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Remove logging when ngModel is missing from the directive instance #401

Open
sszdh opened this issue Nov 4, 2015 · 9 comments
Open

Remove logging when ngModel is missing from the directive instance #401

sszdh opened this issue Nov 4, 2015 · 9 comments

Comments

@sszdh
Copy link

sszdh commented Nov 4, 2015

Hi there,
I think, in case of using ui-sortable without ng-repeat, ngModel in directive definition should be optional and no log should be thrown in console.

Case of ng-repeat-free:

<ul ui-sortable="uiSortableProperties">
<% @items.each do |item| -%>
    <li class="movable">
        <%= item.text %>
    </li>
<% end -%>
    <li>....</li>
<ul>
@thgreasi
Copy link
Contributor

thgreasi commented Nov 4, 2015

Actually, in v0.14.x the ng-repeat will be required. If there is not need to bind with a model, then you could just do a $('...').sortable() in a simple directive.
I will keep this issue open thought and we can revisit in case there is more people requesting something like this.

@thgreasi
Copy link
Contributor

thgreasi commented Nov 4, 2015

Moreover, this directive reverts the changes to the DOM after the drop happens and relies on the model change and the ng-repeat to actually create the final result. That was required in v0.12.0 because of the extra HTML comments that angularjs in v1.2 started to add.

@sszdh
Copy link
Author

sszdh commented Nov 4, 2015

@thgreasi, I understand, but it will be lead us to duplicate jquery/angular usage and duplicate configuration in single application.

It will be DRY & good practice to use one library for single usecase in all over the APP.

Thanks.

@thgreasi
Copy link
Contributor

thgreasi commented Nov 4, 2015

Something like this should be enough, just remember to use $scope.apply().

@sszdh
Copy link
Author

sszdh commented Nov 4, 2015

Sorry, but Bad solution.
If you actually require ngModel, so you should throw exception not log arbitary element in console

@thgreasi
Copy link
Contributor

thgreasi commented Nov 4, 2015

We actually started logging info messages in the console, because there were tons of issues opened, claiming for bugs, but most of these people just forgot to use the ng-model. On the other hand, there where people like you, that just wanted the sorting interaction without effecting anything inside angular. That was the reason that there is an if (ngModel) and there is a log.

If logging bother you, then I assume that you should already be using $logProvider.debugEnabled(true) to disable logging on your production build. Or even better disable the debug data altogether.

What is the use case that you are trying to achieve and this issue is blocking it?

@sszdh
Copy link
Author

sszdh commented Nov 5, 2015

@thgreasi, I understand the reason of if/else.
Just logging info does not make sense for me in first place. I'm just trying to help :)

Anyway we should say thanks for this great package +1

@thgreasi
Copy link
Contributor

thgreasi commented Nov 5, 2015

@sszdh is there a specific use case that troubles you?
Should we just rename the issue to something like "remove logging possible configuration errors"?
Can it be closed?

@sszdh
Copy link
Author

sszdh commented Nov 5, 2015

@thgreasi, no special trouble! but seeing something like this, specially second line ( element's specifications ) :

(!) ui.sortable: ngModel not provided! 
[div.ng-isolate-scope, context: div.ng-isolate-scope, jquery: "2.1.4", constructor: function, selector: "", toArray: function…]

in browser's console, makes no sense in production.
I think renaming the issue would be good choice :)
Cheers

@thgreasi thgreasi changed the title ngModel in directive should be optional. Remove logging when ngModel is missing from the directive instance Nov 5, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants