小编Pie*_*uwe的帖子

如何在JavaPoet中添加"任何类型"问号?

我正在使用JavaPoet生成代码.

在生成的代码中的某处,我想添加一个具有以下参数的方法.

...
    public B someMethod(final AbstractObjectBuilder<Persoon,?> builder) {
       ...
    }
...
Run Code Online (Sandbox Code Playgroud)

所以我的JavaPoet代码看起来应该是这样的

    //This does not compile, since I don't know what to put as last argument (questionmark)
ParameterizedTypeName parameterizedTypeName = ParameterizedTypeName.get(AbstractObjectBuilder.class, propertyType,?);

ParameterSpec parameterSpec = ParameterSpec.builder(parameterizedTypeName, name+"Builder", Modifier.FINAL).build();

MethodSpec modMethod = MethodSpec.methodBuilder(name)
                        .addModifiers(Modifier.PUBLIC)
                        .addParameter(parameterSpec)
                        .returns(TypeVariableName.get("B"));
...
Run Code Online (Sandbox Code Playgroud)

java code-generation javapoet

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

如何为下拉选项创建指令?

假设我在应用程序中为国家/地区使用了相当多的下拉选项(也称为组合框)。\n为了避免一遍又一遍地重复相同的代码,我想为此创建一个指令。

\n\n

但是:使用以下指令并不能满足我的所有期望(见下文),而复制粘贴模板确实满足我的所有期望。

\n\n
app.directive(\'countrydropdown\', function($compile) {\n  return {\n    restrict: \'E\', //attribute or element\n    scope: {\n      countryUri: \'=\'\n    },\n    templateUrl: \'countrydropdown.html\',\n    controller : function($scope) {\n      $scope.listItems = [ \n        {name: \'Afghanistan\', code: \'AF\'},\n        {name: \'\xc3\x85land Islands\', code: \'AX\'},\n        {name: \'Albania\', code: \'AL\'},\n      ];      \n
Run Code Online (Sandbox Code Playgroud)\n\n

我的模板在哪里:

\n\n
<div>\n  model (inside directive): {{countryUri}}\n\n   <ui-select ng-model="countryUri" theme="selectize" >\n    <ui-select-match placeholder="Select or search a country in the list...">{{$select.selected.name}}</ui-select-match>\n    <ui-select-choices repeat="\'/api/countries/\'+country.code as country in listItems | filter: $select.search">\n      <span ng-bind-html="country.name | highlight: $select.search"></span>\n      <small …
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-directive angular-ui-select

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

角度日历 subFn 不是函数

我在使用 Angular 5 日历组件时遇到问题 https://mattlewis92.github.io/angular-calendar

日历呈现完美,包括事件等。但是,使用mwlCalendarPreviousViewmwlCalendarNextView指令不起作用。

点击然后确实出现以下错误:

ERROR TypeError: subFn is not a function
    at CalendarPreviousViewDirective.onClick (angular-calendar.js:239)
    at Object.eval [as handleEvent] (PlanningOverview.html:58)
    at handleEvent (core.js:13581)
    at callWithDebugContext (core.js:15090)
    at Object.debugHandleEvent [as handleEvent] (core.js:14677)
Run Code Online (Sandbox Code Playgroud)

导航到该onClick方法的源代码向我显示以下内容:

 /**
  * @hidden
  * @return {?}
  */
  CalendarNextViewDirective.prototype.onClick = function () {
        var /** @type {?} */ addFn = {
            day: addDays,
            week: addWeeks,
            month: addMonths
        }[this.view];
        this.viewDateChange.emit(addFn(this.viewDate, 1));
    };
    return CalendarNextViewDirective;
Run Code Online (Sandbox Code Playgroud)

这说明subFn确实不是一个函数。

我肯定做错了什么,但我找不到什么......

(我在 Angular 5.0.00 上使用 …

angular angular-calendar

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