I've been trying unsuccessfully for the past hour to get the list of objects declared in my angularJS controller to populate the dropdown menu. When I click on an object in the dropdown list I want the controller to then call on the factory called "API" which then returns the html page that corresponds with the object selected.
HTML
<html ng-app="app">
<head>
<link rel="stylesheet" href="css/bootstrap.min.css" />
</head>
<nav class="navbar navbar-default">
<div class="container"> <!-- top intro part -->
<div class="navbar-header">
<a class="navbar-brand" href="#/"> OPENCV 3.0.0</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li><a href="#/"><i class="fa fa-home"></i> Home</a></li>
<li><a href="#/about"><i class="fa fa-shield"></i> About</a></li>
<li><a href="#/contact"><i class="fa fa-comment"></i> Contact</a></li>
</ul>
</div>
</nav>
<body ng-controller="MainController">
<div class="row">
<div class="col-md-10"> <!-- opencv dropdown menu -->
<div id="opencvFilters">
<form class="form-horizontal" role="form">
<label class="control-label col-md-2">Opencv Filters :</label>
<div class="col-md-10">
<select class="form-control"
ng-model="template"
ng-options="t.name for t in templates">
<!--ng-change="Opencv_Controllers(filter)">-->
<option value=""> Select Filter</option>
</select>
</div>
</form>
</div>
</div>
</div>
<div ng-include="template.url"><div>
<script src="js/angular.min.js"></script>
<script src="js/ui-bootstrap-tpls-0.14.3.min.js"></script>
<script src="js/app.js"></script>
</body>
</html>
angularJS
var app = angular.module("app", ["ui.bootstrap"]);
//http://stackoverflow.com/questions/18571001/file-upload-using-angularjs
app.factory("API", function ($http) {
return {
uploadImage: function (image) {
$http.post("upload.php", image);
}
}
)};
app.controller("MainController", ["$scope, API", function($scope, API) {
$scope.imageUrl = "";
$scope.template = "";
$scope.templates = []; // Declare Array
$scope.templates.push("MakeGray"); // Push object into array
$scope.templates.push("Canny");
$scope.template = $scope.templates[0];
$scope.add = function() {
var f = document.getElementById('file').files[0];
var r = new FileReader();
r.onloadend = function(e) {
var data = e.target.result;
API.uploadImage(data)
.success(function (imgUrl) {
$scope.imageUrl = imgUrl;
})
.error (function (error) {
});
}
r.readAsBinaryString(f);
}
}]);