我有一张bootstrap 4卡,我想隐藏字幕的溢出(并显示"......").我怎样才能做到这一点?如果可能,使用纯引导代码......
<div class="card-block p-1">
<p class="card-title">Test object</p>
<p class="card-subtitle text-muted">Added by Someone with a long name</p>
<p class="card-text mx-auto text-center"><span class="badge badge-pill badge-danger">€ 800</span></p>
</div>
Run Code Online (Sandbox Code Playgroud) 我想在我的 NodeJS 应用程序中实现存储库模式,但我遇到了循环需求的麻烦(我猜......)。
我如何尝试实现它:
首先:我的存储库模式设计正确吗?
我的课程:
personRepository.js
const PersonModel = require('./model');
const Person = require('./person');
class PersonRepository {
constructor() {
this._persons = new Set();
}
getAll( cb ) { // To Do: convert to promise
let results = new Set();
PersonModel.find({}, 'firstName lastName', (err, people) => {
if (err) {
console.error(err);
}
people.forEach((person, index) => {
let foundPerson = new Person(person._id.toString(), person.firstName, person.lastName, person.email, person.birthday);
results.add(foundPerson);
});
this._persons = results;
if (cb) cb(this._persons);
});
}
getById(id) …Run Code Online (Sandbox Code Playgroud) 我的要求是,我希望能够{title: "test", price: undefined}通过$ http.post从我的angular-app中将一个对象发送到我的nodejs应用程序(以便能够通过mongoDB中的Mongoose更新删除价格键)。
问题:
代码提取
console.log(object)
$http.post(url, object)
Run Code Online (Sandbox Code Playgroud)
{title: "test", price: undefined}{title: "test"}==>为什么我的有效载荷不包含完整的对象?如何添加价格:有效载荷中未定义?
我正在努力学习如何使用AngularJS,我偶然发现了一个我无法解决的问题......
下面的代码应该: - 显示2个视图:1显示左侧的一些名称("接收者")和一个显示主要内容(一个介绍或相应人员的列表("currentReceiver")) - 通过$导航state.go到相应的"wishlist"并将URL更改为"... /#/ wishlist /"
我的代码似乎只有在我第一次点击名字时才有效...一旦我点击一次,网址就会保持为空('... /#/')并显示介绍页面......
有人可以解释一下我做错了什么或者我应该在哪里调试这个问题......?
我的index.html的一部分
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar" ui-view="wishlists">
</div>
<div class="col-sm-20 col-sm-offset-3 col-md-10 col-md-offset-2 main" ui-view="wishes">
</div>
</div>
</div>
<!-- scripts -->
...
</body>
Run Code Online (Sandbox Code Playgroud)
wishlist.tmpl.html (左侧的视图'wishlist'模板希望链接到functon"setCurrentReceiver")
<ul class="nav nav-sidebar">
<li ng-repeat="receiver in receivers" ng-class="{'active': isCurrentReceiver(receiver)}">
<a href="#" ng-click="setCurrentReceiver(receiver)">{{receiver.name}}</a>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
gimmi-app.js (在函数setCurrentReceiver中使用$ state.go)
angular.module('Gimmi', [
'ui.router',
'wishlist',
'wishlist.wish',
'wishlist.receiver'
])
.config(function($stateProvider, $urlRouterProvider){
$stateProvider
.state('gimmi', {
url: '',
abstract: true
})
;
$urlRouterProvider.otherwise('/');
})
.controller('MainCtrl', function ($scope, …Run Code Online (Sandbox Code Playgroud) 我有与ngrx get value in function几乎相同的问题,但我想知道答案(请参阅该主题中的评论)是否仍然是当今的最佳实践。
我的情况是:
我有一个可行的解决方案:我在 ngOnInit() 中使用订阅函数,并使用 Observable 中的值设置一个局部变量。因此,我不再需要使用异步管道,我可以轻松地将值传递给某些函数...这听起来像是最好的选择,但在我寻找答案的任何地方,我都会看到“避免使用订阅”。
所以我想知道:
我的问题是我想要一种一致的方法来处理 ngrx 值,但现在看起来我需要根据情况使用两种方法:
(令我惊讶的是:很难在互联网上找到明确的答案......)
我想知道如何防止复制以下代码中的代码。我复制了这个函数wishModel.createWish()。复制代码的原因是:
感谢您帮助我改进我的代码!
if (copyExistsOnList) {
var copyWarningPopup = $uibModal.open({...});
copyWarningPopup.result.then(function (wish) {
wishModel.createWish(newWish, userID, userID, wish._id);
});
} else {
wishModel.createWish(newWish, userID, userID, wish._id);
}
Run Code Online (Sandbox Code Playgroud) angularjs ×2
angular ×1
bootstrap-4 ×1
http ×1
javascript ×1
ngrx ×1
node.js ×1
overflow ×1
promise ×1
redux ×1