我正在使用Angular UI路由器,并希望重新加载当前状态并刷新所有数据/重新运行控制器以获取当前状态及其父级.
我有3个州级别:directory.organisations.details
directory.organisations包含一个包含组织列表的表.单击表中的项目会加载directory.organisations.details并使用$ StateParams传递项目的ID.因此,在详细信息状态中,我加载此项目的详细信息,编辑它们,然后保存数据.到目前为止都很好.
现在我需要重新加载此状态并刷新所有数据.
我试过了:
$state.transitionTo('directory.organisations');
Run Code Online (Sandbox Code Playgroud)
哪个进入父状态,但没有重新加载控制器,我想因为路径没有改变.理想情况下,我只想保留在directory.organisations.details状态并刷新父级中的所有数据.
我也尝试过:
$state.reload()
Run Code Online (Sandbox Code Playgroud)
我在API WIKI for $ state.reload上看过这个"(控制器现在重新修复的错误,很快就会修复)."
任何帮助,将不胜感激?
我正在使用Angular JS - ui.bootstrap.typeahead:
我想单击一个按钮并聚焦输入字段并自动显示预先输入建议下拉列表.我有一个指令,当单击按钮时自动聚焦输入字段.如何自动显示下拉列表,以便用户可以使用向下箭头或单击,以快速选择用户?
我创建了一个带有ui-bootstrap JS文件的Plunker,可以修改:
http://plnkr.co/edit/Z79LY0OYlwFc3wirjxol?p=preview
这是我的完整脚本:
<!doctype html>
<html ng-app="plunker">
<head>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.2/angular.js"></script>
<script src="ui-bootstrap-tpls-0.10.0.js"></script>
</head>
<body>
<script>
angular.module('plunker', ['ui.bootstrap'])
.directive('focusMe', function($timeout, $parse) {
return {
//scope: true, // optionally create a child scope
link: function(scope, element, attrs) {
var model = $parse(attrs.focusMe);
scope.$watch(model, function(value) {
if(value === true) {
$timeout(function() {
element[0].focus();
});
}
});
}
};
});
function TypeaheadCtrl($scope, $http) {
$scope.selected = undefined;
$scope.states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', …Run Code Online (Sandbox Code Playgroud) 我有一个ng-repeat,每行都有多个UI-Bootstrap Datepickers.当选择日期并且选择器关闭时,我试图在我的控制器中调用一个函数.我已经尝试使用UI-Event来捕获模糊事件,但是当调用它时模型尚未更新.我的问题是如何在选择器关闭时获得所选日期?我可以做类似的事情ui-event="{ blur : 'myBlurFunction( $event, this.text)' },还是有另一种方法来获取onClose事件的数据?
<li ng-repeat="....">
<div ng-click="openEditStartCal($event, ticket)">
<input ui-event="{ blur : 'blurredStartDate( $event, ticket, this.text)' }"
type="text"
starting-day="2"
show-button-bar="false"
show-weeks="false"
class="form-control addTicketDateInput"
datepicker-popup="dd MMM"
ng-model="ticket.StartDate"
is-open="startEditTicketOpened && currentTicketUpdating == ticket.TicketId"
min-date="{{today()}}"
max-date="'2015-06-22'"
datepicker-options="dateOptions"
date-disabled="disabled(date, mode)"
ng-required="true" close-text="Close" />
</div>
Run Code Online (Sandbox Code Playgroud)
我有一个奇怪的问题,Date当它通过$ http.put传递给API时发生了变化,我怀疑是时区问题:
Datepicker触发ng-change事件 - console.log:
Tue Jun 10 2014 00:00:00 GMT+0100 (GMT Summer Time)
使用Angular $ http.put传递给API ...
当它击中提琴手时:
StartDate=2014-06-09T23:00:00.000Z
如您所见,日期从6月10日到6月9日.
我怎样才能阻止这种更改日期?这是导致变化的时区吗?API和客户端都在Localhost上运行.
除此之外:
当第二次单击该字段并选择了datepicker启动/日期时,第二次出现问题:
CONSOLE.LOG:
Wed Aug 06 2014 22:00:00 GMT+0100 (GMT Summer Time)
收到的提琴手数据:
StartDate=2014-08-06T21:00:00.000Z
javascript date-format timezone-offset angularjs angular-ui-bootstrap
我试图将数组传递 int[]给我的函数,然后删除该数组中主键的所有记录.
此行.Where(t => personIds.Contains(t.PersonId)).ToList()抛出错误:
'int[]' does not contain a definition for 'Contains' and the best extension method overload 'System.Linq.Queryable.Contains<TSource>(System.Linq.IQueryable<TSource>, TSource)' has some invalid arguments
这是我的控制器:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Description;
using Hercules.WebApi.Models;
namespace Hercules.WebApi.Controllers
{
public class TicketController : ApiController
{
private MyWebApiContext db = new MyWebApiContext();
[Route("Ticket/removeTicketPeople")]
public void RemoveTicketPeople([FromUri]int ticketId, [FromBody]int[] personIds)
{
db.TicketPeople.Where(t => t.TicketId == ticketId)
.Where(t …Run Code Online (Sandbox Code Playgroud) 我有很多行使用'ng-repeat'显示.每行有2个UI-Bootstrap-Datepickers.当有很多行时,页面的加载速度非常慢.
我想只使用一个日期选择器然后在用户点击的字段下动态移动它,或者可能在点击时加载指令并在选择完成后再次卸载它.
有关如何实现这一目标的任何想法?
<li ng-repeat="ticket in data.tickets">
<div ng-click="openAddStartCal($event, ticket)" ng-hide="currentTicketUpdating == ticket.TicketId && currentParameterUpdating =='startCal' && startCalSaving == true">
<input type="text"
starting-day="2"
show-button-bar="false"
show-weeks="false"
class="form-control addTicketDateInput"
datepicker-popup="dd MMM"
ng-model="ticket.StartDate"
ng-change="saveEditStartDate(ticket)"
is-open="checkStartOpened(ticket)"
min-date=""
max-date="'2015-06-22'"
datepicker-options="dateOptions"
date-disabled="disabled(date, mode)"
ng-required="true"
close-text="Close" />
</div>
</li>
Run Code Online (Sandbox Code Playgroud) 我使用angular bootstrap ui(typeahead)尝试在输入聚焦时显示我的客户列表,其中:
lima3app.directive('typeaheadOpenOnFocus', function() {
return {
require: ['ngModel'],
link: function(scope, element, attr, ctrls) {
element.bind('focus', function() {
ctrls.$setViewValue('');
console.log('customer.customer');
});
}
};
});
Run Code Online (Sandbox Code Playgroud)
所以在视图中我设置了我的输入:
<input type="text" class="form-content req" id="form-customer"
name="formcustomer"
typeahead="customer as customer.customer for customer in customerList | filter:{customer:$viewValue}"
typeahead-on-select="onCustomerSelect($item)"
typeahead-append-to-body="true"
typeahead-open-on-focus
ng-model="customer.customer"
focus="true"
required="required">
Run Code Online (Sandbox Code Playgroud)
但代码,不起作用.有没有办法做到这一点?
使用Angular JS - UI路由器,我需要从父视图project.details到我的子视图进行通信project.details.tasks.我的孩子如何查看访问父视图的范围?另外我希望我的父视图能够在我的子视图上调用函数?我怎样才能做到这一点?
这是我想要做的一个粗略的例子:
.state('project.details', {
url: "/:id",
template: '<a ng-click="[target-route??]>childFunction()">',
controller: function($scope){
$scope.parentString = "parent value";
}
})
.state('project.details.tasks', {
url: "/tasks",
templateUrl: "project.details.tasks.html",
controller: function($scope){
console.log("how do I get" + $scope.parentString + " here?";
$scope.childFunction = function() { console.log('Parent calling');
}
})
Run Code Online (Sandbox Code Playgroud)