Answer the question
In order to leave comments, you need to log in
Why is String data not being put into $scope?
Good evening. Essence of the question:
there is an object that stores the fields on which the graph is built
$scope.placeObject = {
place: [
{
name: 'some name 1',
opacity: graphOpacity,
value: 0,
text: 'some text 1'
},
{
name: 'some name 2',
opacity: graphOpacity,
value: 0,
text: 'some text 2'
},
{
name: 'some name 3',
opacity: graphOpacity,
value: 0,
text: 'some text 3'
},
{
name: 'some name 4',
opacity: graphOpacity,
value: 0,
text: 'some text 4'
},
]
};
$http.get('../../php_scripts/functionality/votes/get_new_place_data.php').then(function(response) {
$scope.placeObject.place[0].value = response.data[0].index_of_validity;
$scope.placeObject.place[0].text = response.data[0].name;
});
Answer the question
In order to leave comments, you need to log in
<div class="col-md-3">
<raphael-gauge id="place1" config="placeObject.place[0]"></raphael-gauge>
</div>
<div class="col-md-3">
<raphael-gauge id="place2" config="placeObject.place[1]"></raphael-gauge>
</div>
var ratingApp = angular.module('ratingApp', ['angular-raphael-gauge']);
ratingApp.controller('ratingCtrl', function($scope, $http) {
var graphOpacity = 0.55;
$scope.placeObject = {
place: [
{
name: 'some 1',
opacity: graphOpacity,
value: 0,
text: 'some text 1'
},
{
name: 'some 2',
opacity: graphOpacity,
value: 0,
text: 'some text 2'
},
{
name: 'some name 3',
opacity: graphOpacity,
value: 0,
text: 'some text 3'
},
{
name: 'some name 4',
opacity: graphOpacity,
value: 0,
text: 'some text 4'
},
]
};
$http.get('../../php_scripts/functionality/votes/get_new_place_data.php').then(function(response) {
$scope.placeObject.place[0].value = response.data[0].index_of_validity;
$scope.placeObject.place[0].name = response.data[0].name;
console.log($scope.placeObject.place[0].name)
$scope.placeObject.place[1].value = response.data[1].index_of_validity;
$scope.placeObject.place[1].name = response.data[1].name;
console.log($scope.placeObject.place[1].name)
});
});
Похоже что проблема в модуле для отрисовки графика(использую этот http://angular-js.in/angular-raphael-gauge/)
Он отрисовывает только те значения, которые изначально заданы в объекте $scope.placeObject и не обновляет их после get запроса. Можно ли как то отредактировать этот модуль?
If you are plotting using a third-party directive, why are you sure that it correctly tracks the fact that the name of the chart in $scope has changed? Maybe she takes it from there once when initializing it. In order to see the actual contents of $scope, put yourself an angular batarang in chrome
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question