I'm editing a wikipage in SharePoint to be set up like a form. I have a input text that takes in a coach name. When clicking "Add Person" I want it to add this person to a list and then update my ng-repeat but only one or the other will work at a time when I take the other out (i.e. the ng-repeat displays the correct info or the ng-click works with a test alert I made).
Any help is appreciated. Is this possible to do what I'm trying to do? Please note I tried separating this into two different controllers as a workaround with no luck still so the code might look a little weird.
I'm using SharePoint Designer 2013. Code is below
///this will repeat the correct values but only when...
<h1>Coaches Attending</h1>
<div data-ng-app="app">
<ul data-ng-controller="personController">
<li data-ng-repeat="person in people">{{person.name}}</li>
</ul>
</div>
</div>
////....this is taken out of code
<div data-ng-app="app" data-ng-controller="AddPersonController">
Enter Year:
<input type="text" data-ng-model="year">
<input type="text" data-ng-model="year">
<button data-ng-click='sendEmail()'>greet</button>
<hr>
{{year}}
<button ng-click='sendEmail()'>greet</button>
<br><br><br>
</div>
/////////////////////////////////
<script type="text/javascript">
'use strict';
var app = angular.module('app', ['appControllers']);
"use strict";
var appControllers = angular.module('app', []);
appControllers.controller('personController', ['$scope', '$http', function ($scope, $http) {
alert("first controller");
$scope.people =
[{name:'Bobby'},
{name:'Adam'},
{name:'Jivan'}];
alert("second controller");
$scope.sendEmail = function(){
// $scope.year is undefined!!!!
alert($scope.year)
}
}]).controller('AddPersonController', ['$scope', '$http', function($scope, $http){
alert("second controller");
$scope.sendEmail = function(){
// $scope.year is undefined!!!!
alert($scope.year)
}
}]);
</script>