I am beginner in Angular! Help me, please! There is a webapp (local directories browser). I have app.js:
var currentPath = "http://localhost:9298/api/browse";
angular.module("browserApp", [])
.controller("BrowseController", function ($scope, $http) {
function getDirectoryBrowseModel(path) {
$http.get(path, { responseType: "JSON" })
.then(function (response) {
$scope.model = response.data
});
};
getDirectoryBrowseModel(currentPath);
});
and html in index.cshtml:
<div ng-controller="BrowseController">
<span ng-repeat="drive in model.Drives">
{{drive.Name}}
</span>
<div>{{model.CurrentDrive.Name}}</div>
<div>{{model.CurrentDirectory.Path}}</div>
<div ng-repeat="dir in model.Directories">
<a href="#" onclick='$state.reload();'>{{dir.Name}}</a>
</div>
<div ng-repeat="file in model.Files">
{{file.Name}}
</div>
When I run app first time, then It works succesfully and I get my model in my app.js($scope.model = response.data) and in index.cshtml I have my list of directories and files and drives ...
What to do??? When I click on {{dir.Name}} I want to reload app.js controller( or getDirectoryBrowseModel(currentPath)), with new value of currentPath, for example: currentPath = "http://localhost:9298/api/browse?path=C:\";. And I want to see new all directories and files in view index.cshtml. Thanks!!!