【发布时间】:2016-05-16 12:56:52
【问题描述】:
我是 Angular 的初学者! 请帮帮我! 有一个 webapp(本地目录浏览器)。 我有 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);
});
和 index.cshtml 中的 html:
<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>
当我第一次运行应用程序时,它会成功运行,我的 model 在我的 app.js($scope.model = response.data) 和 index.cshtml 中我有我的列表目录、文件和驱动器...
怎么办??? 当我点击 {{dir.Name}} 时,我想用 currentPath 的新值重新加载 app.js 控制器(或 getDirectoryBrowseModel(currentPath)),例如:currentPath = "http://localhost:9298/api/browse?path=C:\";。我想在视图 index.cshtml 中查看新的所有目录和文件。 谢谢!!!
【问题讨论】:
标签: jquery angularjs asp.net-mvc