Question

this is what I am trying to do:

ng-include=" 'views/directives/list_elements/'+ list.type.object | listobjects +'.html' "

without the filter it works fine

Was it helpful?

Solution

Filters work inside of an expression, whereas ng-include assignment is a string. That's why, you can ng-init the value you want to be a part of the URL in the specific controller scope and then use it.

From the documentation

<script>
function Ctrl($scope) {
  $scope.list = [['a', 'b'], ['c', 'd']];
}
</script>
<div ng-controller="Ctrl">
<div ng-repeat="innerList in list" ng-init="outerIndex = $index">
  <div ng-repeat="value in innerList" ng-init="innerIndex = $index">
     <span class="example-init">list[ {{outerIndex}} ][ {{innerIndex}} ] = {{value}};</span>
  </div>
</div>
</div>

For your case, you could do something like:

ng-init="url_part=list.type.object | listobjects +'.html'"

and then use it in your URL.

'views/directives/list_elements/'+url_part

Otherwise, you can also use this same filter within the controller.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top