这是我的Html和JavaScript代码,我想通过函数更改它.
Html:
<div class="container" ng-app="myApp" ng-controller="myController">
<h2>{{title}}</h2>
<ul ng-init="initItems()">
<li ng-repeat="item in items">
<input ng-model="item.name" type="text"/>
<div ng-if="makeVisible == item.id && makeVisible !='' ">
<input ng-model="newname" type="text"/>
<button ng-click="hideme(item.id); rename()" type="button">
<span class="glyphicon glyphicon-ok">
</span>
</button>
<button ng-click="hideme(item.id)" type="button">
<span class="glyphicon glyphicon-remove">
</span>
</button>
</div>
<input ng-click=" showme( item.id)" type="button" value="Rename"/>
</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
JavaScript:
function item(id, name) {
this.id = id;
this.name = name;
};
angular.module('myApp', []).controller('myController', function($scope) {
$scope.items = [];
$scope.makeVisible = "";
$scope.initItems = …Run Code Online (Sandbox Code Playgroud) 我想把参数发送到服务功能.
getQuestions:function(stateCode):questionResource.js
stateCode在dtoResource.rc1Step1DTO()的响应中设置在$ scope中
angular
.module('autoQuote')
//Do initalization on page load
.run(['$log', '$rootScope', '$state', 'dtoResource', 'questionResource', function($log, $rootScope, $state, dtoResource, questionResource) {
$log.info('Post DTO on page load.');
dtoResource.rc1Step1DTO()
.then(questionResource.getQuestions)
.then(function(questions) {
$rootScope.questions = questions;
console.log('Obtained questions. Assigned to rootscope');
})
.then(function() {
console.log('This should be printed after the above methods are done executing');
console.log($rootScope);
});
}])
Run Code Online (Sandbox Code Playgroud)
如何将状态代码传递给其他函数.它在范围上的地位是
$scope.postAutoQuoteObj.SessionInfo.StateCode
Run Code Online (Sandbox Code Playgroud)
以下是代码http://plnkr.co/edit/Op1QDwUBECAosPUC7r3N?p=preview的plunker
我是视频压缩的新手; 但我看到很多条款一遍又一遍地重复.我想知道x.264和libx264和H.264之间的区别是什么?
我想要一个 javascript 中的方法,它获取一个字符串作为其参数,并从嵌套对象返回一个值,如下所示:
var obj = {
place: {
cuntry: 'Iran',
city: 'Tehran',
block: 68,
info: {
name :'Saeid',
age: 22
}
}
};
function getValue(st) {
// st: 'place[info][name]'
return obj['place']['info']['name'] // or obj.place.info.name
}Run Code Online (Sandbox Code Playgroud)
我是 ajax 和 JavaScript 的新手。我想要做的是多次调用 ajax 函数以从资源中获取某些数据,然后将所有数据“推送”到一个数组中,以便我稍后可以在代码中使用它。这是我的代码。
var arr = [];
var users = ["brunofin", "comster404", "ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];
for (i = 0; i < users.length; i++) {
$.ajax({
url: "https://api.twitch.tv/kraken/streams/" + users[i],
success: function(data) {
arr.push(data);
},
error: function(data) {
arr.push("blank");
},
complete: function() {
if (i == users.length) {
console.log(arr); //This seem to print even when the condition isn't true
}
}
});
}
Run Code Online (Sandbox Code Playgroud)
代码的问题在于,即使i不等于,它也会打印到控制台users.length
我的问题是;我如何确保它i == users.length在打印到控制台之前一直等到为真?请记住,我仍然希望该过程是异步的。
我有一个table tr和td.在表数据之间有一个span我想从中获取ID.
在我的jquery代码中,它没有从spanid 返回任何值.
怎么能得到span身份证?
我的HTML
<table border="1" id="t1">
<tr>
<td>
<span class="f1" id="111" onclick="subtract();">Subtract</span>
</td>
</tr>
<tr>
<td>
<span class="f2" id="222" onclick="subtract();">Subtract</span>
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
我的jQuery
$(document).ready(function() {
$("#t1 span").click(function() {
var a = $(this).id();
alert(a);
});
});
Run Code Online (Sandbox Code Playgroud) 我试图通过只允许某些 ID 访问来确保前端的安全。我希望如果有人尝试输入除 之外的任何路线/login/:id,如果他尚未登录,他会收到页面未找到的信息,但它不起作用。
这些是我的路由表和防护:
编辑: 我解决了问题并更新了代码:
应用程序路由.module.ts
// Routing array - set routes to each html page
const appRoutes: Routes = [{
path: 'login/:id',
canActivate: [AuthGuard],
children: []
},
{
path: '',
canActivate: [AuthGuard],
canActivateChild: [AuthGuard],
children: [{
path: '',
redirectTo: '/courses',
pathMatch: 'full'
},
{
path: 'courses',
component: CourseListComponent,
pathMatch: 'full'
},
{
path: 'courses/:courseId',
component: CourseDetailComponent,
pathMatch: 'full'
},
{
path: 'courses/:courseId/unit/:unitId',
component: CoursePlayComponent,
children: [{
path: '',
component: CourseListComponent
},
{
path: 'lesson/:lessonId',
component: …Run Code Online (Sandbox Code Playgroud)javascript ×5
jquery ×3
angularjs ×2
ajax ×1
angular ×1
h.264 ×1
html ×1
libx264 ×1
parameters ×1
routes ×1
typescript ×1
x264 ×1