我正在尝试在我的 Angular 项目中使用 Bootstrap 5.2 的某些部分。它是针对 SASS 配置的,因此我在项目的主 style.scss 中导入 Bootstrap 的 scss 文件。我这样做是因为我使用的是 Angular Material,所以只需要 Bootstrap Grid 和其他一些基本部分。
\n目前我有
\n样式.scss
\n@import "~bootstrap/scss/functions";\n@import "~bootstrap/scss/variables";\n@import "~bootstrap/scss/mixins";\n@import "~bootstrap/scss/root";\n@import "~bootstrap/scss/reboot";\n@import "~bootstrap/scss/type";\n@import "~bootstrap/scss/grid";\nRun Code Online (Sandbox Code Playgroud)\n我只包含 root.scss,因为这是 Bootstrap 文档(https://getbootstrap.com/docs/5.1/customize/sass/#variable-defaults)中描述的,但删除它会使 ng 构建仅在grid.scss 作为 $gutters 变量未定义。然而,包含它后 ng build 的输出是:
\n./src/styles.scss - Error: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):\nSassError: Undefined variable.\n \xe2\x95\xb7\n20 \xe2\x94\x82 @each $color, $value in $theme-colors-rgb {\n \xe2\x94\x82 ^^^^^^^^^^^^^^^^^\n \xe2\x95\xb5\n node_modules\\bootstrap\\scss\\_root.scss 20:27 @import\n src\\styles.scss 22:9 root stylesheet\n\n./src/styles.scss - Error: Module build …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建以下JSON数据:
{
'chart.labels': ['Bob','Lucy','Gary','Hoolio'],
'chart.tooltips': ['Bob did well',
'Lucy had her best result',
'Gary - not so good',
'Hoolio had a good start'
]
}
Run Code Online (Sandbox Code Playgroud)
我正在使用C#并尝试创建一个对象以便执行此操作......类似于:
public class chart{
public string[] chart.labels {get;set;}
public string[] chart.tooltips {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
但显然我不能拥有包含空格的属性.
我该怎么做呢?
更新:
使用JamieC的答案,以下作品完美无缺
public virtual ActionResult CompanyStatus()
{
var labelList = new List<string>() { "Bob", "Lucy", "Gary", "Hoolio" };
var tooltipsList = new List<string>() { "Bob did well", "Lucy had her best result", "Gary - not so good", "Hoolio had a …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用整页Angular Material选项卡,其中包含完整高度且具有居中消息的选项卡.我已经创建了这个stakblitz,因为我无法让它工作.fxFill似乎没有填充,我不确定这是Flexbox布局还是Angular Material的问题.我不想在每个标签内强制高度,因为这似乎打破了灵活布局的要点.
我肯定它很简单,但帮助一个穷困惑的开发人员习惯Bootstrap网格:)
更新 添加高度:计算(100vh - 100px); 到父div,然后到tall.component div使事情工作,但肯定这是一个糟糕的解决方案
我正在寻找将Angular 1应用程序更新为Angular 2并且遇到了我的一个旧指令的问题.
这个想法很简单.当聚焦输入字段时,应添加一个类(md-input-focus),另一个类被删除(md-input-wrapper).然后这个过程应该在"模糊"事件上反转 - 即焦点丢失.
我的旧指令只包括行
.directive('mdInput',[
'$timeout',
function ($timeout) {
return {
restrict: 'A',
scope: {
ngModel: '='
},
link: function (scope, elem, attrs) {
var $elem = $(elem);
$elem.on('focus', function() {
$elem.closest('.md-input-wrapper').addClass('md-input-focus')
})
.on('blur', function() {
$(this).closest('.md-input-wrapper').removeClass('md-input-focus');
})
}
Run Code Online (Sandbox Code Playgroud)
等等...
我显然对我的指示有经典的开始但是已经没有.....技能了
import {Directive, ElementRef, Renderer, Input} from 'angular2/core';
@Directive({
selector: '.mdInput',
})
export class MaterialDesignDirective {
constructor(el: ElementRef, renderer: Renderer) {
// Insert inciteful code here to do the above
}
}
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激.
更新:
HTML看起来像(在输入元素被聚焦之前):
<div class="md-input-wrapper"> …Run Code Online (Sandbox Code Playgroud) 任何人都可以帮助包括Plunker?
只需提交表单,只输入一个必填字段.这将触发验证错误.然后重置调用setPristine和setUntouched的表单 - 两者都应该重置表单但是没有清除验证错误?
我希望表单被清除数据,但也没有显示验证消息(即使我欣赏,因为数据是空白的,它实际上是无效的)
即这个重置功能
$scope.reset = function(){
$scope.newQuestion = angular.copy(tempQuestion);
$scope.forms.setPristine();
$scope.forms.setUntouched();
};
Run Code Online (Sandbox Code Playgroud)
angular ×3
javascript ×2
angularjs ×1
asp.net-mvc ×1
bootstrap-5 ×1
c# ×1
jquery ×1
json ×1
sass ×1