我正在使用角度ui.select,我将选择的值绑定到模型时遇到问题.我正在尝试使用ui.select设置对象的变量ng-model="data".但由于某种原因,它不会选择值不会绑定到模型.这是我正在使用的代码:
<ui-select ng-model="data" ng-disabled="disabled" theme='select2' style="min-width: 300px;" title="some title">
<ui-select-match placeholder="Select a credit status in the list">[[ $select.selected.variable ]]</ui-select-match>
<ui-select-choices repeat="options in options | filter: $select.search">
<p>[[ options.variable ]]</p>
</ui-select-choices>
</ui-select>
Run Code Online (Sandbox Code Playgroud)
在我的情况下,使用它不会将选定的值绑定到模型.然后我使用$parent.data哪个确实有效,但是当我使用多个ui-choose时,只有一个能够一次工作.
一定有什么我做错了任何帮助表示赞赏.
我试图找到一种好方法在一个向量中存储两个不同的类对象,每个对象在向量中有自己的位置,因此可以在需要时存储和访问对象.
我使用了一个结构,但后来我将结构所有的东西存储到矢量中,这不是我想要的,我将举例说明我的意思.
Class A{
public:
void changeNumber(int x) {number = x;}
private:
int number;
};
Class B{
public:
void changeNumber(int x) {number = x;}
private:
int number;
};
struct Object{
A a;
B b;
};
Class Main{
public:
void storeObject(Object ob) {object.push_back(ob);}
private:
std::vector<Object> objects; //when an object is passed both A and B objects are stored within the vector in the same location
};
Run Code Online (Sandbox Code Playgroud)
有没有办法我可以在一个对象中存储两个不同的类对象,但一次只传递一个以便存储,所以我在向量中有自己的索引?
我正在使用 Vue Router,我需要使用router.beforeEach回调来确定是否命中了某个路由。唯一的问题是,当使用回调时,<router-view></router-view>不会呈现任何内容。
app.vue
<template>
<div id="app">
<navComponent></navComponent>
<router-view></router-view>
</div>
</template>
<script>
import navComponent from './nav'
export default {
components: {
navComponent
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
routes.js
import VueRouter from 'vue-router';
export default new VueRouter({
routes: [
{
path: '/',
component: require('./views/home')
},
{
path: '/logout'
}
],
linkActiveClass: 'is-active'
});
Run Code Online (Sandbox Code Playgroud)
app.js
import './bootstrap';
import router from './routes';
import app from './views/app';
router.beforeEach((to, from, next) => { //if this callback was commented out the <router-view></router-view> would render …Run Code Online (Sandbox Code Playgroud)