Javascript Angularjs模块工厂服务问题
我写了一个简单的工厂服务。 这里是小提琴的链接 我无法确定小提琴为什么不起作用。有人能指出问题吗 提前谢谢 更新:--Javascript Angularjs模块工厂服务问题,javascript,angularjs,angularjs-module,Javascript,Angularjs,Angularjs Module,我写了一个简单的工厂服务。 这里是小提琴的链接 我无法确定小提琴为什么不起作用。有人能指出问题吗 提前谢谢 更新:-- var StudentModule=angular.module(“StudentModule”,[]); 函数factoryfuc() { 返回[ {姓名:“麦克莱恩”,年龄:“22”}, {姓名:“sachin”,年龄:“25”} ]; } StudentModule.factory('Studentfactory',factoryfuc); 函数StudentCon
var StudentModule=angular.module(“StudentModule”,[]);
函数factoryfuc()
{
返回[
{姓名:“麦克莱恩”,年龄:“22”},
{姓名:“sachin”,年龄:“25”}
];
}
StudentModule.factory('Studentfactory',factoryfuc);
函数StudentController($scope,Studentfactory)
{
$scope.students=Studentfactory;
}
{{student.name}{{student.age}
我使用的是Angular的最新版本,它运行良好:
我将在这篇文章中包含的代码是经过修改的代码,以遵循正确的命名约定和更好的实践
标记:
<div ng-app="studentModule" ng-controller="studentCtrl">
<table ng-repeat="student in students">
<tr><td>{{student.name}}</td><td>{{student.age}}</td></tr>
</table>
</div>
var studentModule = angular.module("studentModule",[]);
studentModule.factory('studentService',function() {
return [
{name:"maclean", age:"22"},
{name:"sachin", age:"25"}
];
});
studentModule.controller('studentCtrl', function($scope, studentService) {
$scope.students = studentService;
});
我正在使用Angular的最新版本,它运行良好: 我将在这篇文章中包含的代码是经过修改的代码,以遵循正确的命名约定和更好的实践 标记:
<div ng-app="studentModule" ng-controller="studentCtrl">
<table ng-repeat="student in students">
<tr><td>{{student.name}}</td><td>{{student.age}}</td></tr>
</table>
</div>
var studentModule = angular.module("studentModule",[]);
studentModule.factory('studentService',function() {
return [
{name:"maclean", age:"22"},
{name:"sachin", age:"25"}
];
});
studentModule.controller('studentCtrl', function($scope, studentService) {
$scope.students = studentService;
});
我正在使用Angular的最新版本,它运行良好: 我将在这篇文章中包含的代码是经过修改的代码,以遵循正确的命名约定和更好的实践 标记:
<div ng-app="studentModule" ng-controller="studentCtrl">
<table ng-repeat="student in students">
<tr><td>{{student.name}}</td><td>{{student.age}}</td></tr>
</table>
</div>
var studentModule = angular.module("studentModule",[]);
studentModule.factory('studentService',function() {
return [
{name:"maclean", age:"22"},
{name:"sachin", age:"25"}
];
});
studentModule.controller('studentCtrl', function($scope, studentService) {
$scope.students = studentService;
});
我正在使用Angular的最新版本,它运行良好: 我将在这篇文章中包含的代码是经过修改的代码,以遵循正确的命名约定和更好的实践 标记:
<div ng-app="studentModule" ng-controller="studentCtrl">
<table ng-repeat="student in students">
<tr><td>{{student.name}}</td><td>{{student.age}}</td></tr>
</table>
</div>
var studentModule = angular.module("studentModule",[]);
studentModule.factory('studentService',function() {
return [
{name:"maclean", age:"22"},
{name:"sachin", age:"25"}
];
});
studentModule.controller('studentCtrl', function($scope, studentService) {
$scope.students = studentService;
});
您应该始终在帖子中包含代码。您好,我现在已经在帖子中添加了代码。您应该始终在帖子中包含代码。您好,我现在已经在帖子中添加了代码。您应该始终在帖子中包含代码。您好,我现在已经在帖子中添加了代码。你应该始终在帖子中包含你的代码。嗨,我现在已经在帖子中添加了代码。嗨,你的代码工作得很好。即使我使用与我在jsbin中发布的代码相同的代码,它也可以正常工作。是不是它在fiddle中不起作用?@MacleanPinto也许JSFIDLE有问题。您好,您的代码工作正常。即使我使用与我在jsbin中发布的代码相同的代码,它也可以正常工作。是不是它在fiddle中不起作用?@MacleanPinto也许JSFIDLE有问题。您好,您的代码工作正常。即使我使用与我在jsbin中发布的代码相同的代码,它也可以正常工作。是不是它在fiddle中不起作用?@MacleanPinto也许JSFIDLE有问题。您好,您的代码工作正常。即使我使用与我在jsbin中发布的代码相同的代码,它也可以正常工作。是不是它在小提琴上不起作用?@MacleanPinto也许是jsfiddle出了问题。