0

I am trying to pass a scope into ng-include but it doesn't seem to work when I insert it into ng-include. when I put it outside the ng-include... I get the right result but my div doesn't show up when I insert it into ng-include. Any reason why I am losing the scope when I insert the scope inside ng-include?

Index.html:

<select ng-model="ddValue1"
    ng-options="d.text for d in ddOptions1 track by d.value">
</select>

<div ng-include="'{{ddValue1.url}}'"></div>

JS:

$scope.ddOptions1 = [
  {value: 'value1', text: 'Text1', url: 'file path here'},
  {value: 'value2', text: 'Text2', url: 'file path here'}
];
$scope.ddValue1 = {};
$scope.ddValue1.value = $scope.ddOptions1[0].value;

Newdiv.html

<div ng-show="ddValue1.value=='value1'">
    <h1>Value 1</h1>
</div>
2
  • @SaE updated it sorry Commented Aug 2, 2016 at 13:58
  • @SaE from ddOptions1.value... it is being population into the select by ng-options Commented Aug 2, 2016 at 14:00

2 Answers 2

2
<div ng-include=ddValue1.url></div>

Try it. May be single qoute considering it as string rather than your scope propery

Sign up to request clarification or add additional context in comments.

1 Comment

I got it. Remove double quote to.
0

Try:

ng-options="d as d.text for d in ddOptions1 track by d.value"

Let me know if it does not work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.