-
Notifications
You must be signed in to change notification settings - Fork 1.8k
ng-model not working with a simple variable on $scope #18
Comments
Try |
Are you sure of that? I've been using AngularJS a lot since the 1.0 days and never heard about that. Could you please point out to some documentation, I'm missing something. Inside AngularJS documentation they use: <input type="number" ng-model="size" name="size"
min="0" max="10" integer /> <input type="text" ng-model="length" name="length" smart-float /> Here aswell: <input type="text" name="input" ng-model="text"
ng-pattern="word" required ng-trim="false"> Even todomvc: <input id="new-todo" placeholder="What needs to be done?" ng-model="newTodo" autofocus> And the AngularJS documentation for NgModelController/$setViewValue/$viewValue shows: <textarea ng-model="userContent"></textarea> element.html(ngModel.$viewValue || '');
...
ngModel.$setViewValue(html); |
This isn't exactly a bug with Regardless, after mulling it over, I'm not exactly sure how to go about fixing it without dropping the use of A simple way to reproduce this problem: .directive('test', function(){
return {
scope: true,
require: 'ngModel',
link: function($scope, $elm, $attrs, ngModel) {
ngModel.$setViewValue('hi');
}
}
}) I recommend instead opening an issue on AngularJS and asking their advice instead. |
Thanks for the explanations and opening an issue on AngularJS. |
I'm not an asshole in real life. I just play one on television. |
Btw, for the time-being if you MUST use this approach, you can bypass this issue by doing |
Why not but I won't add features since I (my client) don't have currently the need for them. I can refactor the code a bit, remove some hardcoded stuffs, improve doc and examples and simply make it work: I don't think for instance that the Selectize theme has ever been tested. |
I'm surprised no one has been complaining about the lack of multiselect yet. That's like the one major feature i care about. |
Here is a nice explanation: |
- We can select a course, an attendee, a teacher, a room and press "Save" to get it pushed to Parse - LessonFactory get the defineProperty Model treatment with getters and setters - createLesson.html: on a <select> element, ng-model creates an entire new scope so we need to pass it the $parent reference to catch it in the createLessonCtrl. see angular-ui/ui-select#18
Sorry for bringing it back to life again, but... $parent arent updating my model also function controller(){
$scope.editingGeneralCondition = {};
} <ui-select name="generalCondition" ng-model="$parent.editingGeneralCondition" ng-required="true" theme="bootstrap"> Most probably, I'm making some foolish mistake here. |
@thiagodelgado111 just do |
Inside
demo.html
, if you replaceng-model="data.custom"
:by
ng-model="myItem"
:$scope.myItem
never gets set.It's like
ngModelCtrl.$setViewValue(newVal)
cannot bind to a simple variable$scope.myItem
.It will work only if
ng-model
is an object:demo.js
:$scope.myItem = {}
demo.html
:ng-model="myItem.data"
I could not figure out why, any idea?
The text was updated successfully, but these errors were encountered: