0

I am trying to include a processing Canvas inside a angularjs view.It works inside the index.html but not work inside a view.Sample is given below.

https://plnkr.co/edit/3ZaLzswnnVcf71bwrrgp?p=preview

Home.html

        <div class="container">           
            <canvas data-processing-sources="hello.pde"  ></canvas>
            <a href="#/home"> Back</a>
        </div>


Index.html
<!DOCTYPE html>
<html>
    <head lang="en">
    <script src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular-route.min.js"></script>
    <script type="text/javascript" src="main.js"></script>
    <script src="http://cdnjs.cloudflare.com/ajax/libs/processing.js/1.4.1/processing.min.js"></script>
    </head>
    <body>

      <div ng-app="mainApp">
        <ng-view></ng-view>
      </div>

    </body>
</html>

1 Answers1

0

ng-view is a directive from ngRoute. What you should do instead is just include your template:

<div ng-include="Home.html"></div>

If you want to use ng-view you must setup your app to work with ngRoute.

Example

Wilmer SH
  • 1,417
  • 12
  • 20
  • Added it in main.js var mainApp = angular.module("mainApp", ['ngRoute']); mainApp.config(function($routeProvider) { $routeProvider .when('/home', { templateUrl: 'home.html', controller: 'StudentController' }) Does not work.Forgot to paste the code.Thanks for trying to help – vijayakumar gopalakrishnan Feb 04 '16 at 19:49
  • No worries. If you can provide a plunker in the future we can just fix it there and give you a working answer – Wilmer SH Feb 04 '16 at 20:00
  • Added the sample code .Thanks once again https://plnkr.co/edit/3ZaLzswnnVcf71bwrrgp?p=preview – vijayakumar gopalakrishnan Feb 06 '16 at 09:34
  • Thank you for the plunker. I see your problem but it seems to be specific to angulajs working with canvas which is outside of my expertise. [Kapil found a solution here](http://stackoverflow.com/a/21037213/4775223) I hope that helps. – Wilmer SH Feb 08 '16 at 14:02