Javascript 使用angular.js无法显示内容 过滤器示例 评论(上):- {{sampleCon.upper | uppercase}} 评论(下方):- {{sampleCon.lower | lowercase}} 名称 年龄 姓名-{{person.Name}} 年龄-{{person.Age}} app=angular.module(“sampleMod”,[]); 应用程序控制器(“sampleCon”,函数(){ 此参数为“=”; 此参数为“=”; this.array1=[{name:“sahib”, 年龄:17}, {名称:“库库”, 年龄:25}, {姓名:“米娜”, 年龄:45}, {名称:“阿雅安”, 年龄:2}, ] });
我用angular js制作了一个网页,看起来一切正常,但屏幕上看不到包含ng repeat指令的内容。我无法检测到任何错误上面的程序使用变量而不是这个Javascript 使用angular.js无法显示内容 过滤器示例 评论(上):- {{sampleCon.upper | uppercase}} 评论(下方):- {{sampleCon.lower | lowercase}} 名称 年龄 姓名-{{person.Name}} 年龄-{{person.Age}} app=angular.module(“sampleMod”,[]); 应用程序控制器(“sampleCon”,函数(){ 此参数为“=”; 此参数为“=”; this.array1=[{name:“sahib”, 年龄:17}, {名称:“库库”, 年龄:25}, {姓名:“米娜”, 年龄:45}, {名称:“阿雅安”, 年龄:2}, ] });,javascript,html,angularjs,Javascript,Html,Angularjs,我用angular js制作了一个网页,看起来一切正常,但屏幕上看不到包含ng repeat指令的内容。我无法检测到任何错误上面的程序使用变量而不是这个 <html ng-app = "sampleMod"> <head> </head> <body ng-controller = "sampleCon"> <script src = "bower_components/angular/angula
<html ng-app = "sampleMod">
<head>
</head>
<body ng-controller = "sampleCon">
<script src = "bower_components/angular/angular.min.js"></script>
<h1>Filters example</h1>
Comments (upper) :- <input type = "text" ng-model = "sampleCon.upper"><br>
{{sampleCon.upper | uppercase}}<br>
Comments (lower) :- <input type = "text" ng-model = "sampleCon.lower"><br>
{{sampleCon.lower | lowercase}}<br>
<button type = "button">Name</button>
<button type = "button">Age</button>
<div>
<ul>
<li ng-repeat = "person in sampleCon.array1">
<b>Name</b> - {{person.name}}<br>
<b>Age</b> - {{person.age}}<br><br>
</li>
<ul>
</div>
<script>
app = angular.module("sampleMod",[]);
app.controller("sampleCon",function(){
this.upper = "";
this.lower = "";
this.array1 = [{name:"sahib",
age:17},
{name:"kukku",
age:25},
{name:"meena",
age:45},
{name:"ayaan",
age:2},
]
});
</script>
</body>
</html>
HTML应该是
$scope.upper = "";
$scope.lower = "";
$scope.array1 = [{name:"sahib",
age:17},
{name:"kukku",
age:25},
{name:"meena",
age:45},
{name:"ayaan",
age:2},
]
过滤器示例
评论(上):-
{{大写|大写}}
评论(下方):-
{lower |小写}}
-
姓名-{{person.Name}}
年龄-{{person.Age}}
使用变量而不是此
<html ng-app = "sampleMod">
<head>
</head>
<body ng-controller = "sampleCon">
<script src = "bower_components/angular/angular.min.js"></script>
<h1>Filters example</h1>
Comments (upper) :- <input type = "text" ng-model = "sampleCon.upper"><br>
{{sampleCon.upper | uppercase}}<br>
Comments (lower) :- <input type = "text" ng-model = "sampleCon.lower"><br>
{{sampleCon.lower | lowercase}}<br>
<button type = "button">Name</button>
<button type = "button">Age</button>
<div>
<ul>
<li ng-repeat = "person in sampleCon.array1">
<b>Name</b> - {{person.name}}<br>
<b>Age</b> - {{person.age}}<br><br>
</li>
<ul>
</div>
<script>
app = angular.module("sampleMod",[]);
app.controller("sampleCon",function(){
this.upper = "";
this.lower = "";
this.array1 = [{name:"sahib",
age:17},
{name:"kukku",
age:25},
{name:"meena",
age:45},
{name:"ayaan",
age:2},
]
});
</script>
</body>
</html>
HTML应该是
$scope.upper = "";
$scope.lower = "";
$scope.array1 = [{name:"sahib",
age:17},
{name:"kukku",
age:25},
{name:"meena",
age:45},
{name:"ayaan",
age:2},
]
过滤器示例
评论(上):-
{{大写|大写}}
评论(下方):-
{{lower | lowercase}}
-
姓名-{{person.Name}}
年龄-{{person.Age}}
代替
<h1>Filters example</h1>
Comments (upper) :- <input type = "text" ng-model = "upper"><br>
{{upper | uppercase}}<br>
Comments (lower) :- <input type = "text" ng-model = "lower"><br>
{{lower | lowercase}}<br>
<div>
<ul>
<li ng-repeat = "person in array1">
<b>Name</b> - {{person.name}}<br>
<b>Age</b> - {{person.age}}<br><br>
</li>
<ul>
</div>
姓名-{{person.Name}}
年龄-{{person.Age}}
使用
姓名-{{person.Name}}
年龄-{{person.Age}}
而不是
<h1>Filters example</h1>
Comments (upper) :- <input type = "text" ng-model = "upper"><br>
{{upper | uppercase}}<br>
Comments (lower) :- <input type = "text" ng-model = "lower"><br>
{{lower | lowercase}}<br>
<div>
<ul>
<li ng-repeat = "person in array1">
<b>Name</b> - {{person.name}}<br>
<b>Age</b> - {{person.age}}<br><br>
</li>
<ul>
</div>
姓名-{{person.Name}}
年龄-{{person.Age}}
使用
姓名-{{person.Name}}
年龄-{{person.Age}}
因为您可以在控制器中使用$scope
而不是此
。或者,您可以使用-语法
过滤器示例
评论(上):-
{{ctrl.upper | uppercase}}
评论(下方):-
{{ctrl.lower | lowercase}}
名称
年龄
-
姓名-{{person.Name}}
年龄-{{person.Age}}
app=angular.module(“sampleMod”,[]);
应用程序控制器(“sampleCon”,函数(){
var vm=这个;
vm.upper=“”;
vm.lower=“”;
vm.array1=[{name:“sahib”,
年龄:17},
{名称:“库库”,
年龄:25},
{姓名:“米娜”,
年龄:45},
{名称:“阿雅安”,
年龄:2},
]
});
因为您可以在控制器中使用$scope
而不是此
。或者,您可以使用-语法
过滤器示例
评论(上):-
{{ctrl.upper | uppercase}}
评论(下方):-
{{ctrl.lower | lowercase}}
名称
年龄
-
姓名-{{person.Name}}
年龄-{{person.Age}}
app=angular.module(“sampleMod”,[]);
应用程序控制器(“sampleCon”,函数(){
var vm=这个;
vm.upper=“”;
vm.lower=“”;
vm.array1=[{name:“sahib”,
年龄:17},
{名称:“库库”,
年龄:25},
{姓名:“米娜”,
年龄:45},
{名称:“阿雅安”,
年龄:2},
]
});
删除HTML中除
ng controller=“sampleCon”
sampleCon.upper
至upper
sampleCon.lower
至lower
sampleCon.array1
toarray1
或者只需在HTML中的所有位置执行
ng controller=“sampleCon as sampleCon”
删除sampleCon
,除了ng controller=“sampleCon”
sampleCon.upper
至upper
sampleCon.lower
至lower
sampleCon.array1
toarray1
或者只需执行ng controller=“sampleCon as sampleCon”
使用$scope和类似html的
app.controller("sampleCon",function($scope){
$scope.upper = "";
$scope.lower = "";
$scope.array1 = [{name:"sahib",
age:17},
{name:"kukku",
age:25},
]
});
姓名-{{person.Name}}
年龄-{{person.Age}}
使用$scope和类似html的
app.controller("sampleCon",function($scope){
$scope.upper = "";
$scope.lower = "";
$scope.array1 = [{name:"sahib",
age:17},
{name:"kukku",
age:25},
]
});