1

this ng-include not work but the browser console is empty

<div class='pianificazioneOpertion-module'>
  <div class="container-fluid">
    <div  ng-if="step == false" ng-incude src="'pianificazioneModule/patrimonioNonFinanziarioModule/pianificazioneOperationModule/step.html'"></div>
    <div  ng-if="step == true && operation.tipologia=='5'" ng-include src="'pianificazioneModule/patrimonioNonFinanziarioModule/pianificazioneOperationModule/venditaDonazione.html'"></div>
  </div>
</div>
6
  • 1
    Try ng-include="'pianifi.... The src attribute is only applicable on the <ng-include> element version of the directive Commented Aug 9, 2016 at 9:00
  • What happens if you remove the ng-if statements? Have you verified that the path is correct? Commented Aug 9, 2016 at 9:00
  • Why are you using single quotes inside double quotes for src at ng-include? Commented Aug 9, 2016 at 9:00
  • @JuanjoSalvador because it's required Commented Aug 9, 2016 at 9:01
  • @Mr.White yes the path is correct and if i remove the ng-if statements the result is always that Commented Aug 9, 2016 at 9:04

1 Answer 1

1

You can't use ng-if and ng-include in that way. Use this instead.

<div class='pianificazioneOpertion-module'>
  <div class="container-fluid">
    <div  ng-if="step == false">
      <ng-incude src="'pianificazioneModule/patrimonioNonFinanziarioModule/pianificazioneOperationModule/step.html'"></ng-include>
    </div>
    <div ng-if="step == true && operation.tipologia=='5'">
      <ng-include src="'pianificazioneModule/patrimonioNonFinanziarioModule/pianificazioneOperationModule/venditaDonazione.html'"></ng-include>
    </div>
  </div>
</div>

This is because ng-include is a tag itself.

Check Angular docs for ngInclude https://code.angularjs.org/1.4.12/docs/api/ng/directive/ngInclude

UPDATE

Check this:

In addition, the browser's Same Origin Policy and Cross-Origin Resource Sharing (CORS) policy may further restrict whether the template is successfully loaded. For example, ngInclude won't work for cross-domain requests on all browsers and for file:// access on some browsers.

From Angular Docs. If you're trying to execute your code from file:// instead of http:// (running from node server, by example) it won't work because CORS policy may block it.

Run from Apache/nginx/Node Http server.

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

1 Comment

Can you post your complete code? Maybe there is a problem with the controller.

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.