Search code examples
angularjssharepoint-2013web-parts

Angular JS Code is not working in App Webpart created in SharePoint 2013


I have created an app web part in an App which was created using Visual Studio 2013.

I am writing a very basic code in Angular JS. Pease find the below code.

<div ng-app="myApp">
<b>Welcome to AngularJS world in SharePoint 2013!</b>
 <div ng-controller="MyController"  class="ng-scope">
 <p>Input something in the input box:</p>
    <p>Name: <input type="text" ng-model="name"></p>
    <p>{{name}}</p>
   </div>
 </div>

The above code is not working properly whereas same code is working fine when I am not using App web part.

Also, I am giving correct reference to Angular JS. I am placing this reference code in head section of the page.


Solution

  • Place the below codes in your web page

    <script type="text/javascript">
    var app = angular.module('myApp', []);
    app.controller('MyController', function($scope){ });
    </script>