Sharepoint 2013 won't work with Angularjs -


i tried run simple input test on sharepoint 2013 site. worked @ first after other experimenting within same page in different content editors (i did not touch input test) broke , shows search double brackets. have tried implementing in content editor , script editor nothing seems work. shows text , {{search}}

<script src=".../siteassets/javascript/angular.min.js"></script>  <script src=".../siteassets/javascript/jquery-2.1.4.min.js"></script>  <div>       <input type="text" ng-model="search">       <p>you're searching for: {{search}}</p>  </div>

also can't figgure out why simples hello world won't show should. shows double brackets.

var app = new angular.module("mainapp", []);    app.controller("hellocontroller", function ($scope) {  	$scope.greeting = 'hello';  });      angular.bootstrap(document, ['mainapp']);

above controller , below .html.

<script type="text/javascript" src=".../siteassets/javascript/angular.min.js"></script>  <script type="text/javascript" src=".../siteassets/javascript/hellocontroller.js"></script>     <div ng-app='mainapp' ng-controller='hellocontroller'>      <p>{{greeting}}, world</p>  </div>

i have tested minimal download strategy features effect on these problems not make difference.

i hope can help!

br, noora

you need bootstrap angular app on angular.element ready after dom loaded properly.

code

angular.element(document).ready(function() {      angular.bootstrap(document, ['mainapp']); }); 

you should call angular.bootstrap() after you've loaded or defined modules. cannot add controllers, services, directives, etc after application bootstraps.

doc link


Comments