Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
179
rated 0 times [  184] [ 5]  / answers: 1 / hits: 16168  / 11 Years ago, wed, december 4, 2013, 12:00:00
mapApp.controller(myController, function ($scope,$http) {
$scope.namePlaceHolder= Name;
$scope.name = ;
};


I bound a scope variable to an html input as follows.



<input id=foo type=text placeholder={{namePlaceHolder}} ng-model=name value={{name}}/>


If a user types something in text box the $scope.name property changes. But when I change it using javascript the $scope.name data doesn't change.



on(document.getElementById(button), click, function (e) {
document.getElementById(foo).value = ascd...;
})


This code does not populate $scope.name data.


More From » angularjs

 Answers
202

Accesing scope from external element:



on(document.getElementById(button), click, function (e) {
var scope = angular.element(document.getElementById(foo)).scope();
scope.name = hello, World!;
})

[#73916] Monday, December 2, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
darennevina

Total Points: 422
Total Questions: 128
Total Answers: 105

Location: Comoros
Member since Tue, Mar 14, 2023
1 Year ago
;