Jump to content
Helio13

Forçar o refresh

Recommended Posts

Helio13

O meu problema é o seguinte, estou a fazer um filtro e depois quero saber o numero total do que foi filtrado.

O problema é que eu faço o filtro e não me mostra o numero, apenas á segunda vez que faço e mudo o filtro, parece que ele só faz o refresh á segunda.

Há maneira de forçar isso?

O meu código é este:

<form class="custom">
	<select id="customDropdown" class="small button dropdown secondary radius" ng-model="filterSolution"
			ng-change="selectMovieFilter()">
		<option DISABLED value="">
			<script type="text/javascript">document.write(solutions_dropdown_text)</script>
		</option>
		<option ng-repeat="solution in SolutionResultList.objects" ng-click="addFilterSolution(solution)" value="{{solution.id}}">
			{{solution.SolutionName}}
		</option>
	</select>
<label>
		Number:
  <input type="textfield" name="total" id="total" disabled />
</label>
</form>

var MovieModule = angular.module('MovieModule', ['ngResource']).constant('MOVIES', 'MovieModule')
.directive('myRepeatDirective', function () {
	return function (scope, element, attrs) {
		if (scope.$last) {
			console.log(scope.$index+1);
var total = scope.$index+1
document.getElementById('total').value = total;
		}
	};
});

$scope.addFilterSolution = function (solution) {
	$scope.filterMovieBySolution = solution.SolutionName;
	console.log($scope.filterMovieBySolution);
}
$scope.solutionFilter = function (disk) {
 var filteredItems = [];
	for (var key in $scope.DiskResultList['objects']) {
		if ($scope.DiskResultList['objects'][key].id == disk.id) {
			$scope.solution = $scope.DiskResultList['objects'][key].IdSolution;
		}
	}

	if ($scope.filterMovieBySolution == "")
		return true;
	if ($scope.solution[0].SolutionName == $scope.filterMovieBySolution)
		return true;
	else
		return false;
}

Alguém me pode ajudar?

Share this post


Link to post
Share on other sites
Helio13

Isso faz me o refresh da página toda e vai me buscar os valores originais, o que não quero

Share this post


Link to post
Share on other sites
taviroquai

@Helio

Nas instruções javascript estas a usar scope.$last. Não será que queres usar a variavel $scope do angularJS?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.