Javascript ng在内部单击ng重复不工作
我正在使用routeProvider路由到“views/userspace.html”,它使用“UserspaceController” “views/userspace.html”识别此控制器并将请求设置为$http请求。这个请求可以在文件中工作,我可以在“views/userspace.html”中看到值(在ng repeat中)。但是,在同一个控制器中,我定义了似乎不起作用的Javascript ng在内部单击ng重复不工作,javascript,angularjs,angularjs-ng-repeat,angularjs-ng-click,route-provider,Javascript,Angularjs,Angularjs Ng Repeat,Angularjs Ng Click,Route Provider,我正在使用routeProvider路由到“views/userspace.html”,它使用“UserspaceController” “views/userspace.html”识别此控制器并将请求设置为$http请求。这个请求可以在文件中工作,我可以在“views/userspace.html”中看到值(在ng repeat中)。但是,在同一个控制器中,我定义了似乎不起作用的$scope.videoClick功能。知道为什么吗 var application = angular.mo
$scope.videoClick
功能。知道为什么吗
var application = angular.module("tss.application",
[
"ngRoute",
"ui.bootstrap"
]);
application.config(function($routeProvider)
{
$routeProvider
.when("/", {
templateUrl : "views/main.html",
controller: "LoginController"
})
.when("/files", {
templateUrl : "views/userspace.html",
controller: "UserspaceController"
});
});
userspace\u controller.js
angular.module('tss.application').controller("UserspaceController",
function($scope, $log, $http, $uibModal)
{
$http(
{
url : "/dirlist",
method : "GET",
}).then(function successCallback(response)
{
$scope.lists = response.data;
},
function errorCallback(response)
{
window.alert("Dir list could not be get");
});
$scope.videoClick = function()
{
$log.info('received.');
$uibModal.open(
{
templateUrl: '/views/content.html',
});
};
});
userspace.html
<li ng-repeat="list in lists" ng-click="videoClick(list.src)">{{list.name}}</li>
{{list.name}
更改函数以接受参数
$scope.videoClick = function(val) {
$log.info('received.');
$uibModal.open({
templateUrl: '/views/content.html',
});
};
或者更改HTML中的函数
<li ng-repeat="list in lists" ng-click="videoClick()">{{list.name}}</li>
{{list.name}
更改函数以接受参数
$scope.videoClick = function(val) {
$log.info('received.');
$uibModal.open({
templateUrl: '/views/content.html',
});
};
或者更改HTML中的函数
<li ng-repeat="list in lists" ng-click="videoClick()">{{list.name}}</li>
{{list.name}
这是因为在你的
$scope.videoClick = function()
{
$log.info('received.');
$uibModal.open(
{
templateUrl: '/views/content.html',
});
};
您有一个不需要的逗号,这使得函数抛出一个错误,因为它需要另一个属性
此外,如果您使用的是通过HTML传递的变量,则应使用Sajeetharan的答案。这是因为在
$scope.videoClick = function()
{
$log.info('received.');
$uibModal.open(
{
templateUrl: '/views/content.html',
});
};
您有一个不需要的逗号,这使得函数抛出一个错误,因为它需要另一个属性
另外,如果您使用的是通过HTML传递的变量,则应使用Sajeetharan的答案。如何登录应用程序?用户名-n,密码-ado您有一个团队查看器来登录和修复?让我们来。密码是什么?我如何登录应用程序?用户名-n,密码-ado您有一个团队查看器来登录和修复?让我们来。密码是什么?