标签: angular-ui

如何在AngularJS中使用按键事件?

我想在下面的文本框中捕获回车键按下事件.为了更清楚,我使用a ng-repeat来填充tbody.这是HTML:

<td><input type="number" id="closeqty{{$index}}" class="pagination-right closefield" 
    data-ng-model="closeqtymodel" data-ng-change="change($index)" required placeholder="{{item.closeMeasure}}" /></td>
Run Code Online (Sandbox Code Playgroud)

这是我的模块:

angular.module('components', ['ngResource']);
Run Code Online (Sandbox Code Playgroud)

我正在使用资源填充表,我的控制器代码是:

function Ajaxy($scope, $resource) {
//controller which has resource to populate the table 
}
Run Code Online (Sandbox Code Playgroud)

angularjs angular-ui angularjs-directive

404
推荐指数
7
解决办法
45万
查看次数

如何使用ui-router中的ui-sref将参数传递给控制器

我需要传递并接收两个参数到我想转移到使用ui-srefui-router的状态.

比如使用以下链接将状态转换为homewith foobar参数:

<a ui-sref="home({foo: 'fooVal', bar: 'barVal'})">Go to home state with foo and bar parameters </a>
Run Code Online (Sandbox Code Playgroud)

控制器中的接收foobar值:

app.controller('SomeController', function($scope, $stateParam) {
  //..
  var foo = $stateParam.foo; //getting fooVal
  var bar = $stateParam.bar; //getting barVal
  //..
});     
Run Code Online (Sandbox Code Playgroud)

我在控制器中得到undefined$stateParam.

有人可以帮我理解如何完成它吗?

编辑:

.state('home', {
  url: '/',
  views: {
    '': {
      templateUrl: 'home.html',
      controller: 'MainRootCtrl'

    },

    'A@home': {
      templateUrl: 'a.html',
      controller: 'MainCtrl'
    },

    'B@home': {
      templateUrl: 'b.html',
      controller: …
Run Code Online (Sandbox Code Playgroud)

html javascript angularjs angular-ui angular-ui-router

364
推荐指数
3
解决办法
37万
查看次数

重新加载当前状态 - 刷新数据

我正在使用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上看过这个"(控制器现在重新修复的错误,很快就会修复)."

任何帮助,将不胜感激?

angularjs angular-ui angular-ui-router

323
推荐指数
10
解决办法
44万
查看次数

ui-bootstrap-tpls.min.js和ui-bootstrap.min.js有什么区别?

在cdnjs 的Angular-UI-Bootstrap页面上说:

Twitter的Bootstrap的Native AngularJS(Angular)指令.占用空间小(5 kB gzipped!),无需第三方JavaScript依赖(jQuery,Bootstrap JavaScript)!

......并且可以选择

//cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.6.0/ui-bootstrap-tpls.min.js
Run Code Online (Sandbox Code Playgroud)

//cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.6.0/ui-bootstrap.min.js
Run Code Online (Sandbox Code Playgroud)

差异这些显示出微妙的差异,我似乎无法找到任何文件......

简而言之,除非您要创建自定义模板,否则请使用tpls.

它在此处记录:github.com/angular-ui/bootstrap/tree/gh-pages#build-files(也从主页链接).简而言之,-tpls版本捆绑了默认的Bootstrap模板.在任何情况下,您应该只包括列出的文件之一. - 谢谢pkozlowski.opensource

angularjs angular-ui angular-ui-bootstrap

195
推荐指数
2
解决办法
8万
查看次数

将$ scope注入角度服务函数()

我有一个服务:

angular.module('cfd')
  .service('StudentService', [ '$http',
    function ($http) {
    // get some data via the $http
    var path = 'data/people/students.json';
    var students = $http.get(path).then(function (resp) {
      return resp.data;
    });     
    //save method create a new student if not already exists
    //else update the existing object
    this.save = function (student) {
      if (student.id == null) {
        //if this is new student, add it in students array
        $scope.students.push(student);
      } else {
        //for existing student, find this student using id
        //and update it.
        for (i …
Run Code Online (Sandbox Code Playgroud)

angularjs angular-ui angular-ui-router

106
推荐指数
4
解决办法
17万
查看次数

Angular ui-router中$ state.transitionTo()和$ state.go()之间的区别

在AngularJS中,我看到有时我们使用$state.transitionTo(),有时我们使用$state.go().任何人都可以告诉我他们的差异,以及何时应该使用另一个?

javascript url-routing angularjs angular-ui angular-ui-router

103
推荐指数
2
解决办法
8万
查看次数

否则在StateProvider上

使用angular-ui-router,如何在$ stateProvider上使用其他方法或者我该如何使用它?

angularjs angular-ui angular-ui-router

94
推荐指数
3
解决办法
9万
查看次数

selectMatch上的angular ui-bootstrap typeahead回调?

我正在使用角度ui-bootstrap typeahead,我想用它作为一种方法来获取很多选择,所以我需要在selectMatch方法启动时获取所选值但我找不到怎么做在我的控制器中

<div class='container-fluid' ng-controller="TypeaheadCtrl">
<pre>Model: {{selected| json}}</pre>
<input type="text" ng-model="selected" typeahead="state for state in states | filter:$viewValue">
Run Code Online (Sandbox Code Playgroud)

如果我看到所选的值,每按一次键我都会得到更改...

scope.$watch('selected', function(newValue, oldValue) {... });
Run Code Online (Sandbox Code Playgroud)

我知道方法selectMatch是当用户按下回车或点击列表时调用的方法,但我不知道如何对其进行回调...

谢谢 !

angularjs bootstrap-typeahead angular-ui

92
推荐指数
2
解决办法
9万
查看次数

你可以覆盖AngularUI Bootstrap中的特定模板吗?

我很好奇是否有办法覆盖ui-bootstrap-tpls文件中的单个特定模板.绝大多数默认模板都符合我的需求,但有一些我想要替换的特定模板,而不是通过抓取所有默认模板并将它们连接到非tpls版本的整个过程.

angularjs angular-ui angular-ui-bootstrap

87
推荐指数
4
解决办法
7万
查看次数

如何检测指令中的当前状态

我正在使用AngularUI的路由,我想做一个,ng-class="{active: current.state}"但我不确定如何在这样的指令中准确检测当前状态.

angular-ui

86
推荐指数
3
解决办法
13万
查看次数