I have this code:
<li ng-repeat="objekt in driversList" class="mix {{objekt.Objekt.Type}}">
<a href="objekttest.html" data-ajax="false"
ng-click="objekt.Objekt.Active='yes'">
<img ng-src="../images/thumbs/{{objekt.Objekt.Thumb}}.jpg"
style="margin-right:0;" >
<span id="list">{{objekt.Objekt.Name}}{{objekt.Objekt.Active}}</span>
<span id="listmala">{{objekt.Objekt.Type}}</span>
</a>
</li>
objekt.Objekt.Active
changes when I click the corresponding <li>
tag.
However, on the other HTML link, I have:
<div ng-repeat="objekt in driversList">
{{objekt.Objekt.Name}} {{objekt.Objekt.Active}}
</div>
This time, objekt.Objekt.Active
keeps the default value (i.e. 'no').
Is it possible to change a scope variable permanently so that it is changed on some other HTML element?
Here's my controller code:
angular.module('aki', [
'aki.controllers'
]);
angular.module('aki.controllers', []).
controller('akicontroller', function($scope,$rootScope) {
//$scope.toggle = function(){
//$scope.driversList.
//}
$rootScope.active='da';
$scope.driversList = [
{
Objekt: {
Name: 'Saint & Sinner',
Type: 'nightclub',
Thumb: 'Sinner',
Active:'no'
}
},
{
Objekt: {
Name: 'Corner Cafe',
Type: 'cafe',
Thumb: 'corner caffe',
Active:'no'
}
},...
...
EDIT: I'm making multipage application without Ajax
ng-click
should use a function in$scope
to set the original object's value.ng-click="setActive($index)"
otherwise you're only changing the value within the subscope created byng-repeat
. – m.e.conroy Apr 28 at 18:40