I have the following in an angular partial
<h1>{{tournament.name}}</h1>
<accordion close-others="true">
<accordion-group>
<accordion-heading>
<p>Schools</p>
</accordion-heading>
<input ng-model="newSchoolName" placeholder="new school name">
<button class="btn-sm" ng-click="addNewSchool()" ng-disabled="!newSchoolName">Add New School</button><br/>
...
and the following in my controller
tournamentControllers.controller("ConsoleController",['$scope','$http', function($scope, $http){
$scope.update = function(){
console.log("update");
$http({method:'GET', url: '/tournament/console_api'}).
success(function(data,status,headers,config){
$scope.tournament = data;
}).error(function(data,status,headers,config){
console.log("error");
});//Initial schools
};
$scope.update();
$scope.addNewSchool = function(){
$http.post('/tournament/add_school',{
new_name : $scope.newSchoolName
}).success(function(data,status,headers,config){
$scope.tournament = data;
}).error(function(data,status,headers,config){
console.log("error");
});
};
If I comment out the ui.bootstrap parts (but don't remove them) it works perfectly, but if I leave them in it ends up sending the empty JSON object "tournament" ={} which I'm guessing comes from the line where I say "$scope.tournament = data;",
I'm using angular 1.2.9, angular route, angular sanitize ui.bootstrap 0.11.0 and bootstrap.css. Thanks in advance.
EDIT: Here are the results of the post request as given by the rails console logs
Parameters: {"tournament"=>{}} when not working
Parameters: {"new_name"=>"gwgfwf", "tournament"=>{}} when working
After trying a lot of debugging, it has to do with a child scope being created inside the accordion and that not including the newSchoolName. No clue how to fix that though.