小编oju*_*rni的帖子

Angular 4安装

我想在我的Windows 7上安装Angular版本4.*我
目前正在使用Angular版本1.6.*

我尝试了下面的命令

npm install @angular/{common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router,animations}@next --save
Run Code Online (Sandbox Code Playgroud)

但它不起作用

任何人都可以指导我安装和创建角4项目..

angularjs npm-install angular-cli angular

4
推荐指数
1
解决办法
5万
查看次数

如何在成功处理程序之外使用 $http 承诺响应

$scope.tempObject = {};

 $http({
   method: 'GET',
   url: '/myRestUrl'
}).then(function successCallback(response) {
   $scope.tempObject = response
   console.log("Temp Object in successCallback ", $scope.tempObject);
}, function errorCallback(response) {

});
console.log("Temp Object outside $http ", $scope.tempObject);
Run Code Online (Sandbox Code Playgroud)

我得到响应successCallback,但没有得到$scope.tempObject外界$http。它的显示undefined

如何访问response$scope.tempObject之后$http

angularjs angular-http angular-promise

2
推荐指数
1
解决办法
3997
查看次数

如何在鼠标悬停时使用ng-mouseover隐藏和显示输入元素

这是我的代码: -

<div class="input-group">
    <input class="form-control" ng-model="name" required />
    <span class="input-group-btn">
        <button class="btn btn-primary" type="button" >
               <i class="fa fa-plus"></i>
        </button>
    </span>
</div>
Run Code Online (Sandbox Code Playgroud)

这里我使用bootstrap类input-group,其中包含两个元素<input>,<span>
所以在这里我想在鼠标悬停时显示该按钮.
所以我试着用ng-mouseover

<span class="input-group-btn">
     <button class="btn btn-primary" type="button" ng-mouseover="open" >
            <i class="fa fa-plus"></i>
     </button>
</span>
Run Code Online (Sandbox Code Playgroud)

哪里开放: -

$scope.open = true;
Run Code Online (Sandbox Code Playgroud)

我认为ng-mouseover是更好的选择,但如果有任何其他简单的方法....请告诉我

angularjs

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

AngularJs - 使用指令在点击事件上显示隐藏密码

我现在有一个密码输入字段和一个带有该输入字段的按钮
,如果输入字段的类型是密码,即type="password",然后单击该按钮,它应该变成文本type="text"
即如果我再次单击同一个按钮,它应该更改type="password"

意味着它应该切换value输入元素的类型

我已经使用控制器完成了此操作,它与控制器一起工作正常。下面是使用控制器的工作代码

但是如果我想使用指令而不是控制器,那么如何使用指令处理此切换条件

目的 - 我想在多个输入元素上使用此功能

超文本标记语言

<div class="input-group">
   <label>Password</label>
   <input type="{{inputType}}" class="form-control" ng-model="password" />
   <span ng-click="show()">show</span>
</div>
Run Code Online (Sandbox Code Playgroud)

控制器

$scope.inputType = 'password';

$scope.show = function() {
  if ($scope.inputType === 'password') {
     $scope.inputType = !$scope.inputType;
     $scope.inputType = 'text';
  } else {
     $scope.inputType = !$scope.inputType;
     $scope.inputType = 'password';
  }
}
Run Code Online (Sandbox Code Playgroud)

我尝试使用指令 - 下面是我的试用代码,
我不知道如何<input />使用指令更改元素的类型

指示

.directive('myDir', function() {
    require: 'ngModel',
    link: function (scope, element, attrs) { …
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-directive

1
推荐指数
1
解决办法
3039
查看次数